Skip to content
/ exrn Public

A Command-line File Renaming Tool Based on Regular Expressions

License

Notifications You must be signed in to change notification settings

Intro-iu/exrn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exrn 🔄

A Safe & Powerful Batch File Renamer with Regex Magic

Rust License: MIT

Transform your files like a wizard! 🧙

Features 🌟

  • 🎯 Precision Matching with regex patterns
  • 🔄 Smart Replacement using capture groups
  • 👮 Safety First - Interactive confirmation & dry-run preview
  • 🚀 Blazing Fast - Built with Rust performance
  • 📦 Cross-Platform - Works on Windows/macOS/Linux
  • 📝 Visual Feedback - Colorized diff previews

Installation ⚡

Via Cargo (Recommended)

cargo install --git https://github.com/Intro-iu/exrn.git

From Source

git clone https://github.com/Intro-iu/exrn.git
cd exrn
cargo install --path .

Usage 🛠️

Basic Syntax

exrn -s "GLOB_PATTERN" -r "SOURCE_REGEX" "TARGET_PATTERN" [OPTIONS]

Key Options

Option Description
-s, --sources File glob patterns (e.g., *.txt)
-r, --rule Regex match and replacement pattern
-y, --yes Auto-confirm all actions

Examples 🧪

1. Change File Extensions (With Confirmation)

exrn -s "*.txt" -r '^(.*)\.txt$' '$1.md'

Interactive Output:

Matching files...
[1] notes.txt => notes.md
[2] draft.txt => draft.md

Planned changes (2 files):
Do you want to proceed with the renaming? [y/N]: y

Renaming completed! 2/2 files successfully renamed

2. Auto-Confirm with -y Flag

exrn -s "temp_*" -r 'temp_' 'final_' -y

Output:

Auto-confirm enabled
[1] temp_file1 => final_file1
[2] temp_file2 => final_file2
Renamed 2 files successfully

3. Date Format Conversion

exrn -s "*.log" -r '(\d{4})-(\d{2})-(\d{2})' '$2$3$1'

📆 Converts 2023-08-15.log08152023.log

Safety Measures 🔒

exrn includes multiple protection layers:

if source == target { /* Skip identical paths */ }
if target.exists() { /* Prevent overwrites */ }
if new_name.is_empty() { /* Block empty names */ }

License 📄

This project is licensed under the MIT License - see the LICENSE file for details.


💡 Pro Tip: Always check the preview before confirming!
🐞 Found an issue? Report it here
⭐ Love exrn? Give us a star on GitHub!

About

A Command-line File Renaming Tool Based on Regular Expressions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages