A Safe & Powerful Batch File Renamer with Regex Magic ✨
Transform your files like a wizard! 🧙
- 🎯 Precision Matching: Supports both standard GLOB patterns and direct Shell-expanded paths.
- 🔄 Smart Replacement: Use standard Regex Capture Groups (e.g.,
$1,$2) for complex renaming. - ⛓️ Chain Renaming: Safely handles dependency chains (e.g.,
A -> B,B -> C) using topological sorting. - 🎨 Rich TUI:
- Interactive Mode: Select/Deselect files with a modern Terminal UI (Ratatui-based).
- Smart Preview: Headless modes (Dry Run/Auto-confirm) also display a beautiful table preview even without interaction.
- Line Wrapping: Automatically handles long filenames by wrapping text within columns.
- CI Friendly: Detects non-TTY environments (CI/Pipes) and falls back to plain text output automatically.
- 🛡️ Safety First:
- Dry Run mode to preview without touching files.
- Collision detection.
- 🚀 Blazing Fast: Built with Rust.
cargo install --git https://github.com/Intro-iu/exrn.gitgit clone https://github.com/Intro-iu/exrn.git
cd exrn
cargo install --path .exrn -s [SOURCES] -r 'REGEX' 'REPLACEMENT' [OPTIONS]Tip: It is recommended to use single quotes
'...'for regex patterns to prevent Shell from incorrectly expanding$1or*.
| Option | Short | Description |
|---|---|---|
--sources |
-s |
File glob patterns or file paths (e.g. '*.txt' or file.txt) |
--rule |
-r |
Required. Regex pattern and replacement string (e.g. '(.*)\.txt' '$1.md') |
--dry-run |
-d |
Print the planned changes and exit without modifying anything |
--sort |
Sort the output list by source filename (Default: true) | |
--yes |
-y |
Auto-confirm all prompts (Non-interactive mode) |
When running in a terminal without -y or -d, exrn launches a rich interactive interface:
- ↑/↓: Navigate through the file list.
- Space: Toggle selection (include/exclude file from renaming).
- Enter: Confirm and execute the selected renames.
- Esc/q: Quit without making changes.
Note: In Dry Run or Auto-Confirm modes,
exrnwill still display the table preview (without interactivity) if running in a terminal. In CI environments, it automatically falls back to plain text.
Preview what would happen:
exrn -s '*.txt' -r '(.*)\.txt' '$1.md' --dry-runIf you have files part1.txt, part2.txt, part3.txt and want to shift them naming-wise:
# Safely handles renaming part2 -> part3 even if part3 exists (but is also being moved)
exrn -s 'part*' -r 'part(\d+)' 'part${1}_next'Convert 2023-01-01_log.txt to log_2023-01-01.txt:
exrn -s '*.txt' -r '(\d{4}-\d{2}-\d{2})_(.*)\.txt' '$2_$1.txt'You can let your shell handle the globbing:
exrn -s *.png -r 'Img_(.*)' 'Picture_$1'This project is licensed under the MIT License - see the LICENSE file for details.
💡 Pro Tip: Always use --dry-run (-d) first when trying complex regexes!
🐞 Found an issue? Report it here
⭐ Love exrn? Give us a star on GitHub!
