Batch Renamer
批量文件重命名工具,支持多种命名模式、正则表达式、预览和撤销功能。适用于需要批量整理文件的场景,如照片整理、文档归档、下载文件重命名等。
utopiabenben
@utopiabenben
Install
$ openclaw skills install @utopiabenben/batch-renamerBatch Renamer - 批量文件重命名工具
功能特性
- ✅ 多种命名模式:序号、日期、自定义前缀/后缀
- ✅ 正则表达式支持:灵活匹配和替换
- ✅ 预览功能:先预览,确认后再执行
- ✅ 撤销操作:支持撤销最近一次重命名
- ✅ 安全可靠:自动备份原始文件名
安装
npm install -g batch-renamer
快速开始
1. 序号重命名
batch-renamer rename ./photos --pattern "photo_{001}.jpg"
2. 日期重命名
batch-renamer rename ./docs --pattern "doc_{YYYY-MM-DD}.md"
3. 正则表达式替换
batch-renamer rename ./downloads --regex "s/^DSC_/photo_/"
4. 预览模式(不实际执行)
batch-renamer rename ./photos --pattern "photo_{001}.jpg" --preview
5. 撤销操作
batch-renamer undo ./photos
详细使用说明
命名模式变量
{001}- 三位序号(自动补零){01}- 两位序号{1}- 一位序号{YYYY}- 四位年份{MM}- 两位月份{DD}- 两位日期{HH}- 两位小时{mm}- 两位分钟{original}- 原始文件名(不含扩展名){ext}- 原始扩展名
正则表达式语法
使用 JavaScript 正则表达式语法:
# 替换前缀
batch-renamer rename ./files --regex "s/^old_/new_/"
# 删除空格
batch-renamer rename ./files --regex "s/\s+/_/g"
# 提取数字
batch-renamer rename ./files --regex "s/.*?(\d+).*/file_$1/"
安全措施
- 预览模式:默认先显示预览,需要确认后才执行
- 自动备份:执行重命名前自动保存映射关系
- 撤销功能:随时可以撤销最近一次操作
- dry-run 选项:使用 --preview 或 --dry-run 查看效果
示例场景
场景 1:整理照片
# 将 DSC_0001.jpg 重命名为 2026-03-05_001.jpg
batch-renamer rename ./photos --pattern "{YYYY-MM-DD}_{001}.jpg"
场景 2:整理下载文件
# 将 "下载 (1).pdf" 重命名为 document_001.pdf
batch-renamer rename ./downloads --pattern "document_{001}.{ext}"
场景 3:批量替换
# 将所有文件名中的 "v1" 替换为 "v2"
batch-renamer rename ./files --regex "s/v1/v2/g"
配置文件
可以在项目根目录创建 .batch-renamer.json 配置默认选项:
{
"preview": true,
"backup": true,
"pattern": "{001}.{ext}"
}
故障排除
- 撤销失败:确保在同一目录下执行,且备份文件未被删除
- 正则表达式错误:检查语法,可使用 --preview 先测试
- 权限问题:确保有文件读写权限
更新日志
v0.1.0 (2026-03-05)
- 初始版本发布
- 支持基础重命名功能
- 支持预览和撤销
Top skills in this category
Agent Browser
@matrixyHeadless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection
Auto-Updater Skill
@maximepradesAutomatically update Clawdbot and all installed skills once daily. Runs via cron, checks for updates, applies them, and messages the user with a summary of what changed.
Free Ride - Unlimited free AI
@shaivpidadiManages free AI models from OpenRouter for OpenClaw. Automatically ranks models by quality, configures fallbacks for rate-limit handling, and updates opencla...
Automation Workflows
@jk-0001Design and implement automation workflows to save time and scale operations as a solopreneur. Use when identifying repetitive tasks to automate, building workflows across tools, setting up triggers and actions, or optimizing existing automations. Covers automation opportunity identification, workflow design, tool selection (Zapier, Make, n8n), testing, and maintenance. Trigger on "automate", "automation", "workflow automation", "save time", "reduce manual work", "automate my business", "no-code automation".
Desktop Control
@matagulAdvanced desktop automation with mouse, keyboard, and screen control