| name | batch-rename |
| description | This skill should be used when the user wants to batch rename multiple files at once.
It handles various rename patterns including sequential numbering, find/replace, prefix/suffix
addition, regular expression matching, extension filtering, and recursive subfolder processing.
This skill is triggered when the user mentions "ๆน้้ๅฝๅ", "batch rename", "ๆน้ๆนๅ",
"ๆน้ไฟฎๆนๆไปถๅ", or similar requests for renaming multiple files simultaneously.
|
Batch Rename Skill
Purpose
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.
When to Use
Use this skill when user wants to:
- Rename multiple files at once (ๆน้้ๅฝๅ)
- Add sequential numbers to filenames
- Find and replace text in filenames
- Add date prefixes or other prefixes/suffixes
- Use regex patterns for complex renaming
- Filter files by extension before renaming
- Process files in subfolders recursively
Usage Workflow
Step 1: Identify User's Rename Intent
Ask the user (or infer from their request):
- Target directory/folder path
- Rename pattern type:
- Sequential numbering:
photo_{n}.jpg โ photo_001.jpg
- Find & replace: Replace specific text in filenames
- Add prefix/suffix: Add date or other text
- Regex pattern: For complex transformations
- File extension filter (optional)
- Whether to process subfolders recursively
Step 2: Construct Rename Command
Use the scripts/batch_rename.py script with appropriate arguments:
python scripts/batch_rename.py --path "C:/folder" --pattern "number" --format "file_{n:03d}" --ext "jpg"
python scripts/batch_rename.py --path "C:/folder" --pattern "replace" --find "old" --replace "new"
python scripts/batch_rename.py --path "C:/folder" --pattern "prefix" --prefix "2026-" --ext "*"
python scripts/batch_rename.py --path "C:/folder" --pattern "suffix" --suffix "_backup" --ext "*.txt"
python scripts/batch_rename.py --path "C:/folder" --pattern "regex" --regex "(\d+)" --replace "ID_$1"
python scripts/batch_rename.py --path "C:/folder" --pattern "number" --format "doc_{n}" --ext "pdf" --recursive
Step 3: Execute Rename
Run the command. The script will:
- Scan the target directory
- Apply filters (extension, recursive)
- Perform renaming operations
- Report results
Step 4: Report Results
Present a summary showing:
- Number of files renamed successfully
- Any errors or skipped files
- Original โ New name mappings for verification
Script Arguments Reference
| 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 |
Examples
Example 1: Add Sequential Numbers
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"
Example 2: Find and Replace
User: "ๆๆๆๆไปถๅ้็ '_v1' ๆนๆ '_final'"
Command: python scripts/batch_rename.py --path "C:/folder" --pattern replace --find "_v1" --replace "_final"
Example 3: Add Date Prefix
User: "็ปๆๆๆๆกฃๅ ไธๆฅๆๅ็ผ 2026-04-10"
Command: python scripts/batch_rename.py --path "C:/docs" --pattern prefix --prefix "2026-04-10_" --ext "docx"
Example 4: Regex to Normalize
User: "ๆๆๆๆไปถๅ็็ฉบๆ ผๆฟๆขๆไธๅ็บฟ"
Command: python scripts/batch_rename.py --path "C:/folder" --pattern regex --regex "\s+" --replace "_"
Safety Notes
- Always report what will be renamed before executing
- For subfolder operations, be extra careful and confirm the scope
- Use
--ext filter to limit scope when possible
- Script uses
os.rename() which may fail if file already exists at target name