rn 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 adding _before, _after, dates, tags, or variants to filenames without retyping the original name.
$ ls
route_report.csv
$ rn route_report_before.csv
# renames: route_report.csv → route_report_before.csvExpansion happens when the target name begins with the full current name.
Example:
old: route_report.csv
new: route_report_before.csv
Rules:
- If
new_namestarts withold_name - If ending is identical of both files
- If exactly one file matches: rename it.
- If zero or multiple matches: no action; an explanation is printed.
- No wild guessing: requires exactly one match.
- No overwrite: refuses if the target already exists (unless
--forceis used). - No ambiguity: prints candidate files and exits when unsure.
- Atomic rename using the OS rename syscall.
rn is designed for interactive speed and safety, not for risky batch scripts.
$ rn image_before.png
image.png → image_before.png$ rn results_v2.csv
results.csv → results_v2.csv$ rn report.csv
route_report_before.csv → report.csv # only candidate$ rn route.csv
Multiple candidates:
route_report_before.csv
route_raw.csvcargo install rnOr download binaries from Releases and place in your $PATH.
mv 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.