Files
SnapOtter/apps/docs/zh-CN/tools/image/bulk-rename.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

2.5 KiB

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
使用模式模板重命名多个文件并以 ZIP 下载。 2776dcc2f71c human 4b35a9b3af6b

Bulk Rename

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

API Endpoint

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

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

Parameters

Parameter Type Required Default Description
pattern string "image-{{index}}" 带占位符的命名模式(最多 1000 个字符)
startIndex number 1 起始索引编号

Pattern Placeholders

Placeholder Description Example
{{index}} startIndex 开始的顺序编号 123
{{padded}} 补零的顺序编号 010203
{{original}} 不含扩展名的原始文件名 photoIMG_001

原始文件扩展名始终会被保留。

Example Request

curl -X POST http://localhost:1349/api/v1/tools/image/bulk-rename \
  -H "Authorization: Bearer si_your-api-key" \
  -F "file=@photo1.jpg" \
  -F "file=@photo2.jpg" \
  -F "file=@photo3.jpg" \
  -F 'settings={"pattern": "vacation-{{padded}}", "startIndex": 1}'

这会产生:vacation-1.jpgvacation-2.jpgvacation-3.jpg

使用原始文件名:

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 归档。
  • {{padded}} 的补零宽度会根据文件总数自动确定(例如 100 个文件会使用 3 位补零:001002 等)。
  • 文件扩展名会从原始文件名中保留。
  • 文件名会被清理以移除不安全字符。
  • 至少必须提供一个文件。