AI Agent Hub
Back to skills
Batch Rename Files and Folders icon

Batch Rename Files and Folders

Office Efficiency Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Follow https://skillhub.cn/install/skillhub.md to install @user_bb79990a/batch-rename2 into your AI assistant.

About this skill

Problem Solved

When a batch of files comes from downloads, exports, scans, or collaborative workflows, names often do not match the expected convention: missing business prefixes, stale date suffixes, inconsistent casing, or mixed extensions. Renaming them one by one is error-prone and can easily break an already organized directory. This skill addresses a concrete scenario: batch renaming files or folders inside a specified directory using composable rules, with preview-first execution and backup support.

How It Works

The skill first parses the key parameters from the user's request:

  • target_dir: the target directory path
  • targets: process files, folders, or all
  • rules: rename rules, separated by | when multiple
  • backup: whether to create a backup, enabled by default
  • recursive: whether to process subdirectories, disabled by default

Supported rules include prefix, suffix, replace, regex, serial, case, strip, ext, and recursive. For example, prefix:img_|suffix:_v1|replace:_old:_new applies a prefix, a suffix, and text replacement in sequence; regex:(\d+):part$1 can rewrite numbers into a part-prefixed format. By default, the skill enters preview mode and shows the intended changes before execution. After the user confirms with yes, it creates a timestamped backup directory, performs the rename, and reports success and failure counts. Failed items are recorded while processing continues, and the backup directory remains untouched.

Boundaries and Notes

This skill is well suited to well-scoped directory cleanup where the target directory and rules are explicit. It is less appropriate for complex business logic or cross-directory semantic mapping. When using ext, extension filtering is case-insensitive; when using serial, part of the original filename is retained; and regex replacement follows Python re.sub() syntax. Because preview and backup are enabled by default, reviewers should still verify the target directory, backup path, and rule examples before running batch renames in production-like environments.

Use Cases

  • Clean up downloaded timestamped images by adding an img_ prefix and replacing stale markers.
  • Rename exported report files by replacing _old with _new and filtering to selected extensions.
  • Normalize subdirectory document names to uppercase, lowercase, or title case with recursive processing.
  • Rewrite numeric names into part-style labels with serial numbers like 001 and 002, then confirm the preview.

Best For

  • Operations designers who archive campaign assets and need consistent image prefixes and suffixes
  • Operations analysts who clean exported reports by replacing old field names and filtering extensions
  • Knowledge managers who maintain local document libraries and need recursive naming normalization
  • Engineers who organize test data files using regex and serial-number rules