This page was machine-translated. Spotted a mistake?Help improve it.
Skip to content

Bulk Rename

使用带有索引、补零索引和原始文件名占位符的模式模板重命名多个文件。返回一个包含所有重命名文件的 ZIP 归档。

API Endpoint

POST /api/v1/tools/image/bulk-rename

接受包含多个文件和一个 JSON settings 字段的 multipart 表单数据。

Parameters

ParameterTypeRequiredDefaultDescription
patternstring"image-"带占位符的命名模式(最多 1000 个字符)
startIndexnumber1起始索引编号

Pattern Placeholders

PlaceholderDescriptionExample
startIndex 开始的顺序编号123
补零的顺序编号010203
不含扩展名的原始文件名photoIMG_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.jpgvacation-2.jpgvacation-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.jpg2024-trip-IMG_002-2.jpg

Example Response

响应是直接流式传输的 ZIP 文件(不是 JSON 响应)。响应标头为:

Content-Type: application/zip
Content-Disposition: attachment; filename="renamed-a1b2c3d4.zip"

Notes

  • 此工具不处理图像。它只重命名文件并将其打包成 ZIP 归档。
  • 的补零宽度会根据文件总数自动确定(例如 100 个文件会使用 3 位补零:001002 等)。
  • 文件扩展名会从原始文件名中保留。
  • 文件名会被清理以移除不安全字符。
  • 至少必须提供一个文件。