Organize messy folders by moving files into subfolders grouped by extension, date, or category. Use for downloads cleanups and batch file sorting.
Coding
batch-file-rename
Try itBatch file renaming utility with pattern matching, regex, sequence numbering, and dry-run preview. Supports prefix/suffix, case conversion, whitespace cleanup, and recursive directory processing.
What it does
Batch file renaming utility with pattern matching, regex, sequence numbering, and dry-run preview. Supports prefix/suffix, case conversion, whitespace cleanup, and recursive directory processing.
The skill document
Batch File Rename
Safely rename multiple files with preview-first semantics.
When to use it
- Standardize filenames across a directory (e.g., all lowercase, spaces → underscores)
- Add sequential numbers (
photo_001.jpg,photo_002.jpg, …) - Add prefixes or suffixes to batches of files
- Replace patterns in filenames (e.g.,
draft_→final_) - Change extensions in bulk (
.JPG→.jpg,.md→.txt) - Revert accidental renames via generated undo script
Prerequisites
bash4+python3(optional, for Unicode-safe slugify)- No external dependencies required
Quick Start
1. Dry-run (always do this first)
bash scripts/batch-rename.sh --dir /path/to/files --dry-run
Output example:
[DRY-RUN] photo 1.JPG → photo_001.JPG
[DRY-RUN] photo 2.JPG → photo_002.JPG
[DRY-RUN] photo 3.JPG → photo_003.JPG
3 files will be renamed
2. Add sequential numbers
bash scripts/batch-rename.sh --dir ./photos --number --prefix "vacation_" --start 1 --digits 3
3. Pattern substitution
bash scripts/batch-rename.sh --dir ./docs --replace "draft_" --with "final_"
4. Change case + extension
bash scripts/batch-rename.sh --dir ./files --lowercase --ext-lower
5. Full options
bash scripts/batch-rename.sh [OPTIONS]
Options:
--dir DIR Target directory (required)
--dry-run Preview changes without renaming
--number Add sequential numbers
--prefix P Prepend P to each filename
--suffix S Append S before extension
--start N Starting number for --number (default: 1)
--digits N Pad width for --number (default: 3)
--replace FROM Replace FROM pattern in filenames
--with TO Replace with TO (default: empty)
--lowercase Convert filenames to lowercase
--uppercase Convert filenames to uppercase
--ext-lower Convert extensions to lowercase
--ext-upper Convert extensions to uppercase
--glob PAT Only match files matching PAT (default: *)
--undo FILE Undo using a previous rename log
--log FILE Write rename log to FILE (default: /.rename-log-)
-h, --help Show this help
Safety Features
- Dry-run by default — always preview before committing
- Collision detection — aborts if two files would get the same name
- Rename log — every real run writes a log that can
--undo - No overwrite — refuses to overwrite existing files
Undo
Every real run generates /.rename-log-:
RENAME|photo 1.JPG|photo_001.JPG
RENAME|photo 2.JPG|photo_002.JPG
Undo:
bash scripts/batch-rename.sh --undo ./photos/.rename-log-20260816-231500
Examples
Standardize a download folder
bash scripts/batch-rename.sh --dir ~/Downloads --lowercase --ext-lower --replace " " --with "_"
Number photos for a gallery
bash scripts/batch-rename.sh --dir ./gallery --number --prefix "img_" --digits 4 --start 100
Convert .JPG to .jpg in place
bash scripts/batch-rename.sh --dir ./photos --ext-lower --glob "*.JPG"
Script
See scripts/batch-rename.sh for the full implementation.
Related skills
Sort and organize files in a directory by type or by modification date, with dry-run preview, duplicate-name handling, and an auto-generated organization report. Use when the user wants to clean up, sort, categorize, or organize files in a folder, or asks for a file classification/overview report.
Rename academic PDF papers to a standardized format "[Year] [Venue] Title.pdf" using a three-stage pipeline (Extract → Verify → Rename). Use when the user as...
Drive the installed FinalPlace Windows desktop app's auto-rules engine to automatically organize files — auto-sort, move, copy, compress, unzip, or rename fi...
Batch-compile existing Gitea, Obsidian Git, or manual zip material sources into personal or team knowledge bases with preview, confirmation, job tracking, so...
Content-aware file management for workspace files: search (content snippets opt-in via --snippets), dedup, organize, rename, file metadata inspection, and continuous watch mode. Watch mode persists a journal (paths/hashes/sizes/ timestamps/change events) to memory/smart-files-journal.json and can monitor paths outside the workspace when --force is passed. All file mutations (organize/rename) require --force and are dry-run by default.