← 返回
未分类 中文

batch-rename

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...
此技能用于一次性批量重命名多个文件,支持多种重命名模式,包括顺序编号、查找替换等。
1227323804
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 390
下载
💾 0
安装
1
版本
#latest

概述

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):

  1. Target directory/folder path
  2. Rename pattern type:
    • Sequential numbering: photo_{n}.jpgphoto_001.jpg
    • Find & replace: Replace specific text in filenames
    • Add prefix/suffix: Add date or other text
    • Regex pattern: For complex transformations
  3. File extension filter (optional)
  4. Whether to process subfolders recursively

Step 2: Construct Rename Command

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

Step 3: Execute Rename

Run the command. The script will:

  1. Scan the target directory
  2. Apply filters (extension, recursive)
  3. Perform renaming operations
  4. 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

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 04:35 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,349 📥 317,699
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,055 📥 795,968
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 666 📥 323,794