| Crates.io | snipren |
| lib.rs | snipren |
| version | 0.1.5 |
| created_at | 2025-11-18 02:43:51.028697+00 |
| updated_at | 2025-12-09 19:04:50.262342+00 |
| description | Easy rename for unix-like systems |
| homepage | |
| repository | https://github.com/jac18281828/snipren |
| max_upload_size | |
| id | 1937808 |
| size | 50,200 |
rn — A Fast, Safe, Intent-Aware Rename Utilityrn is a small command-line tool for renaming files by inference.
You provide the new name, and rn determines the old name — safely, predictably, and fast.
It streamlines common workflows like:
data.txt → data.csvfile.txt → file_backup.txtMakefile → Makefile.bak$ ls
route_report.csv
$ rn route_report_before.csv
route_report.csv → route_report_before.csv
rn Worksrn uses two complementary matching strategies to infer which file you want to rename:
Matches when the base name is identical but the extension differs.
Examples:
$ rn data.csv
data.txt → data.csv
$ rn report.md
report.txt → report.md
$ rn all_aero_pools.csv
all_aero_pools.txt → all_aero_pools.csv
Rules:
Matches when characters are added in the middle or end of the filename.
Examples:
$ rn route_report_before.csv
route_report.csv → route_report_before.csv
$ rn data_backup.json
data.json → data_backup.json
$ rn Makefile.bak
Makefile → Makefile.bak
$ rn config~
config → config~
Rules:
For any rename to succeed:
--force is used$ rn data.csv
data.txt → data.csv
$ rn image.jpg
image.png → image.jpg
$ rn config.yaml
config.yml → config.yaml
$ rn image_before.png
image.png → image_before.png
$ rn results_v2.csv
results.csv → results_v2.csv
$ rn report_final.txt
report.txt → report_final.txt
$ rn Makefile.bak
Makefile → Makefile.bak
$ rn config~
config → config~
$ rn script.sh.bak
script.sh → script.sh.bak
# Expansion
$ rn route_report_before.csv
route_report.csv → route_report_before.csv
# Reduction (reverse expansion)
$ rn route_report.csv
route_report_before.csv → route_report.csv
When multiple files could match, rn refuses to guess:
$ ls
report.csv report.txt report.md
$ rn report.json
Multiple candidates found for 'report.json':
report.csv
report.txt
report.md
Cannot proceed - ambiguous match.
Solution: Be more specific or rename manually with mv.
Some renames match both extension change AND expansion:
$ rn config.yaml
# Matches extension change: config.(yml) → config.(yaml)
# Also matches expansion: config.yml → config.yaml (yml is prefix of yaml)
# Result: Works fine! (we use OR logic)
This is harmless — the rename succeeds either way.
rn does NOT match when adding a prefix:
$ ls
test.log
$ rn production_test.log
No matching files found for 'production_test.log'
# Rejected: expansion at the start is not allowed
Rationale: Prevents ambiguous matches like data.json matching metadata.json.
Extension change requires both files to have extensions:
$ ls
README
$ rn README.md
README → README.md # Works! (expansion pattern)
$ ls
Makefile LICENSE
$ rn LICENSE
Makefile → LICENSE # FAILS (different base, no match)
Be careful with files that are substrings of each other:
$ ls
test.txt testing.txt
$ rn test.csv
test.txt → test.csv # Works
$ rn testing.csv
testing.txt → testing.csv # Works
$ rn tester.txt
# May match test.txt via expansion (test → tester)
Best Practice: In directories with many similar names, verify the match before confirming.
rn <new_name> [OPTIONS]
OPTIONS:
-f, --force Force rename even if target exists (overwrites)
-h, --help Print help information
--force)rn is designed for interactive use and safety, not for risky batch scripts.
cargo install snipren
Or build from source:
git clone https://github.com/jac18281828/snipren
cd snipren
cargo build --release
cp target/release/rn ~/.local/bin/ # or anywhere in your $PATH
rn?mv: No need to type both the old and new namesrn figures out the restmv requires you to know both names.
rn lets you rename using the name you want, not the name you must type.
Fast for humans, safe by design.
Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE file for details.