← 返回
未分类

batch_rename

Batch rename files with preview (dry-run) support. Supports add prefix/suffix, text replacement, sequential numbering, regex replacement, and case conversion. Use when user wants to rename multiple files at once, rename files in bulk, add prefixes or suffixes to filenames, replace text in filenames, number files sequentially, or convert filename case.
支持预览(试运行)的批量文件重命名工具 功能包含:添加前缀 / 后缀、文本替换、顺序编号、正则替换、文件名大小写转换。 适用场景:批量修改文件名、给文件加前后缀、替换文件名内文字、文件按序号排序命名、统一转换文件名大小写。
user_946e7965
未分类 community v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 62
下载
💾 0
安装
1
版本
#latest

概述

Batch Rename Files

Batch rename files using scripts/batch_rename.py. Always run in dry-run mode first to preview changes, then re-run with --execute to apply.

Quick start

python scripts/batch_rename.py <directory> -m <mode> [options]

Modes

ModeDescriptionRequired Options
------------------------------------
prefixAdd prefix to filenames--prefix
suffixAdd suffix before extension--suffix
replaceReplace text in filenames-p -r
regexRegex substitution-p -r
numberSequential numbering--start N --padding N
prefix_numberPrefix + sequential number--prefix --start N --padding N

Common options

OptionDescription
---------------------
-c, --caseCase conversion: lower, upper, title, capitalize, snake, kebab, camel, pascal
--filter Only rename files matching regex
--ignorecaseCase-insensitive regex matching
--recursiveInclude subdirectories
--noextStrip extensions in number modes
--executeApply changes (skip this flag for dry-run preview)

Usage patterns

Add prefix/suffix

python scripts/batch_rename.py /path/to/files -m prefix --prefix "img_"
python scripts/batch_rename.py /path/to/files -m suffix --suffix "_backup"

Replace text

python scripts/batch_rename.py /path/to/files -m replace -p "old_text" -r "new_text"

Regex replace

python scripts/batch_rename.py /path/to/files -m regex -p "(\d+)" -r "v\1"

Sequential numbering

python scripts/batch_rename.py /path/to/files -m number --start 1 --padding 3
python scripts/batch_rename.py /path/to/files -m prefix_number --prefix "photo_" --start 1 --padding 2

Case conversion

python scripts/batch_rename.py /path/to/files -m replace -p "." -r "." -c lower

Filter by pattern

python scripts/batch_rename.py /path/to/files -m prefix --prefix "img_" --filter "\.jpg$"

Combine operations

python scripts/batch_rename.py /path/to/files -m replace -p " " -r "_" -c lower

Workflow

  1. Run in dry-run mode (no --execute) to preview
  2. Show the preview to the user for confirmation
  3. Re-run with --execute to apply
  4. Report results

Safety notes

  • The script will not overwrite existing files without warning (OS error raised)
  • Non-file entries (directories, symlinks) are automatically skipped
  • Invalid regex patterns are caught and reported before any file access

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-05-17 17:36 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 243,986
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,362 📥 318,707
developer-tools

Github

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