Search K
Bulk Rename
使用带有索引、补零索引和原始文件名占位符的模式模板重命名多个文件。返回一个包含所有重命名文件的 ZIP 归档。
API Endpoint
POST /api/v1/tools/image/bulk-rename
接受包含多个文件和一个 JSON settings 字段的 multipart 表单数据。
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| pattern | string | 否 | "image-" | 带占位符的命名模式(最多 1000 个字符) |
| startIndex | number | 否 | 1 | 起始索引编号 |
Pattern Placeholders
| Placeholder | Description | Example |
|---|---|---|
| 从 startIndex 开始的顺序编号 | 1、2、3 |
| 补零的顺序编号 | 01、02、03 |
| 不含扩展名的原始文件名 | photo、IMG_001 |
原始文件扩展名始终会被保留。
Example Request
bash
curl -X POST http://localhost:1349/api/v1/tools/image/bulk-rename \
-H "Authorization: Bearer si_your-api-key" \
-F "[email protected]" \
-F "[email protected]" \
-F "[email protected]" \
-F 'settings={"pattern": "vacation-{{padded}}", "startIndex": 1}'这会产生:vacation-1.jpg、vacation-2.jpg、vacation-3.jpg
使用原始文件名:
bash
curl -X POST http://localhost:1349/api/v1/tools/image/bulk-rename \
-H "Authorization: Bearer si_your-api-key" \
-F "file=@IMG_001.jpg" \
-F "file=@IMG_002.jpg" \
-F 'settings={"pattern": "2024-trip-{{original}}-{{index}}"}'这会产生:2024-trip-IMG_001-1.jpg、2024-trip-IMG_002-2.jpg
Example Response
响应是直接流式传输的 ZIP 文件(不是 JSON 响应)。响应标头为:
Content-Type: application/zip
Content-Disposition: attachment; filename="renamed-a1b2c3d4.zip"Notes
- 此工具不处理图像。它只重命名文件并将其打包成 ZIP 归档。
的补零宽度会根据文件总数自动确定(例如 100 个文件会使用 3 位补零:001、002等)。- 文件扩展名会从原始文件名中保留。
- 文件名会被清理以移除不安全字符。
- 至少必须提供一个文件。
