tencent cloud

Smart Media Hosting

Product Introduction
Product Overview
Feature Description
Product Strengths
Use Cases
Basic Concept
Purchase Guide
Quick Start
Create Media Library
Initiate request
Service Level API Document
History
Introduction
API Category
Making API Requests
PaaS Service APIs
Official Cloud Disk APIs
Data Types
Error Codes
Business Level API Document
Introduction
Access Token Operation API
Tenant Space Operation API
File Operation API
Directory or Album Operation API
Recycle Bin Operation API
Quota Operation API
Query Task Operation API
Search Operation API
Historical Version Operations API
Directory and File Batch Operation API
Collection Operation API
Error Codes
SDK Documentation
Android SDK
iOS SDK
HarmonyOS SDK
FAQs
Enterprise Network Disk
Product Introduction
Purchase Guide
Quick Start
FAQs
Service Level Agreement
Glossary

Batch Renaming or Moving a Directory or File

PDF
フォーカスモード
フォントサイズ
最終更新日: 2026-01-07 14:28:07

Description

For batch rename or move directory or file.
Note:
Required permissions:
Renaming or moving within the same space: admin, space_admin, or move_directory/move_file/move_file_force. To rename or move both directories and files simultaneously, specify both move_directory and move_file/move_file_force permissions.
Cross-space movement: admin or specify space_admin for both the source space and destination space.
For details about permissions, see Generate Access Token Interface.

Request

Request Example

POST /api/v1/batch/{LibraryId}/{SpaceId}?move&access_token={AccessToken}&user_id={UserId}

Request Parameter

Request parameters.
Description
Type
Required or Not
LibraryId
Media Library ID, obtained after creating a media library in the Media Hosting console. See Create Media Library
String
Yes
SpaceId
Space ID. If the media library is in single-tenant mode, this parameter is fixed as a hyphen (-); if the media library is in multi-tenant mode, you must specify this parameter. For retrieval, see Create Tenant Space
String
Yes
AccessToken
Access token. For retrieval, see Generate Access Token
String
Yes
UserId
User identity recognition. When the access token corresponds to admin permission and the user identity recognition during token application is empty, it is used to temporarily designate user identity. For details, see Generate Access Token
String
No

Request Body

application/json, specify the source path and path to save for rename or move.
Request body example:
[
{
"fromSpaceId":"spaceNJsnjdiq",
"from": "foo/bar_old",
"to": "foo/bar"
},
{
"from": "foo/1.jpg",
"to": "bar/1.jpg"
},
{
"from": "foo/2.jpg",
"to": "bar/2.jpg",
"conflictResolutionStrategy": "overwrite"
}
]
Request body field description:
Request parameters.
Description
Type
Required or Not
fromSpaceId
Specify the space where the source directory or file is located when moving across spaces. Do not specify this field when moving within the same space.
String
No
from
The source directory, album, or file path to be renamed or moved.
String
Yes
to
Target directory, album, or file path
String
Yes
conflictResolutionStrategy
Handling method for filename conflicts, default is rename
ask: Returns HTTP 409 Conflict and error code SameNameDirectoryOrFileExists when conflicts with
rename: automatically rename file when conflicts with
overwrite:
If the target is a directory or album, it defaults to ask and does not support overwrite
If the target is a file, overwrite the existing file
When a file exists in the target space with an earlier version, do not support moving overwrite
String
No
moveAuthority
Whether to allow moving
Boolean
No

Response

Response code

Execution successful.
When multiple projects are renamed or moved asynchronously, return HTTP 202 Accepted.
When fewer projects are renamed or moved synchronously, return HTTP 200 OK (all execution successful) or HTTP 207 Multi-Status (part or all execution failed).

Response Body

application/json
Response body example:
Return HTTP 200 OK or HTTP 207 Multi-Status:
{
"result": [
{
"status": 204,
"moveAuthority":false,
"from": [ "foo", "bar_old" ],
"to": [ "foo", "bar" ]
},
{
"status": 200,
"path": [ "bar", "1 (1).jpg" ],
"from": [ "foo", "1.jpg" ],
"to": [ "bar", "1.jpg" ]
},
{
"status": 204,
"from": [ "foo", "2.jpg" ],
"to": [ "bar", "2.jpg" ]
}
]
}
Return HTTP 202 Accepted:
{ "taskId": 17 }
[
{
"taskId": 17,
"status": 200,
"result": [
{
"status": 204,
"moveAuthority":false,
"from": [ "foo", "bar_old" ],
"to": [ "foo", "bar" ]
},
{
"status": 200,
"path": [ "bar", "1 (1).jpg" ],
"from": [ "foo", "1.jpg" ],
"to": [ "bar", "1.jpg" ]
},
{
"status": 204,
"from": [ "foo", "2.jpg" ],
"to": [ "bar", "2.jpg" ]
}
]
}
]
Response body field description:
Response Parameters
Description
Type
result.status
Rename or move result of individual item:
200: Renamed or moved successfully when conflictResolutionStrategy is rename.
204: Renamed or moved successfully when conflictResolutionStrategy is ask or overwrite.
403/404/409/500: Rename or move failure
String
result.moveAuthority
Whether to allow moving
Boolean
result.path
The final path may differ from the specified path during rename or move operations because automatic renaming may exist.
String Array
result.from and result.to
The corresponding path passed in when making a request in array format
Array
taskId
The task ID for rename or move operations performed asynchronously can be used to query task status via the Query Task API.
String
Query task response body field description:
Response Parameters
Description
Type
status
Query task status.
202: Task in progress
200: All executed successfully
207: Part or all failed to execute
String

Error Codes

This request operation has no special error messages. For common error messages, see Error Codes.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック