Provides powerful batch file renaming capabilities with multiple pattern support. Rename files with sequential numbers, find/replace text, add prefixes/suffixes, use regex patterns, filter by extension, and process subfolders recursively.
Use this skill when user wants to:
Ask the user (or infer from their request):
photo_{n}.jpg → photo_001.jpg
Use the scripts/batch_rename.py script with appropriate arguments:
# Sequential numbering
python scripts/batch_rename.py --path "C:/folder" --pattern "number" --format "file_{n:03d}" --ext "jpg"
# Find and replace
python scripts/batch_rename.py --path "C:/folder" --pattern "replace" --find "old" --replace "new"
# Add prefix
python scripts/batch_rename.py --path "C:/folder" --pattern "prefix" --prefix "2026-" --ext "*"
# Add suffix
python scripts/batch_rename.py --path "C:/folder" --pattern "suffix" --suffix "_backup" --ext "*.txt"
# Regex pattern
python scripts/batch_rename.py --path "C:/folder" --pattern "regex" --regex "(\d+)" --replace "ID_$1"
# Recursive with extension filter
python scripts/batch_rename.py --path "C:/folder" --pattern "number" --format "doc_{n}" --ext "pdf" --recursive
Run the command. The script will:
Present a summary showing:
| Argument | Description | Required |
|----------|-------------|----------|
| --path | Target directory path | Yes |
| --pattern | Rename pattern: number, replace, prefix, suffix, regex | Yes |
| --format | Format string for numbering (e.g., file_{n:03d}) | For --pattern number |
| --find | Text to find | For --pattern replace |
| --replace | Replacement text | For --pattern replace |
| --prefix | Prefix to add | For --pattern prefix |
| --suffix | Suffix to add | For --pattern suffix |
| --regex | Regular expression pattern | For --pattern regex |
| --ext | File extension filter (e.g., jpg, * for all) | No (default: all) |
| --recursive | Process subfolders recursively | No |
User: "把 photos 文件夹里的图片重命名为 IMG_001, IMG_002..."
Command: python scripts/batch_rename.py --path "C:/Users/12891/photos" --pattern number --format "IMG_{n:03d}" --ext "jpg"
User: "把所有文件名里的 '_v1' 改成 '_final'"
Command: python scripts/batch_rename.py --path "C:/folder" --pattern replace --find "_v1" --replace "_final"
User: "给所有文档加上日期前缀 2026-04-10"
Command: python scripts/batch_rename.py --path "C:/docs" --pattern prefix --prefix "2026-04-10_" --ext "docx"
User: "把所有文件名的空格替换成下划线"
Command: python scripts/batch_rename.py --path "C:/folder" --pattern regex --regex "\s+" --replace "_"
--ext filter to limit scope when possible
os.rename() which may fail if file already exists at target name
共 1 个版本