Skip to content

jac18281828/snipren

Repository files navigation

rn — A Fast, Safe, Intent-Aware Rename Utility

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.csv

How rn Works

1. Expansion

Expansion happens when the target name begins with the full current name.

Example:

old: route_report.csv
new: route_report_before.csv

Rules:

  • If new_name starts with old_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.

Safety Guarantees

  • No wild guessing: requires exactly one match.
  • No overwrite: refuses if the target already exists (unless --force is 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.


Examples

Add a tag

$ rn image_before.png
image.png → image_before.png

Add a version

$ rn results_v2.csv
results.csv → results_v2.csv

Safe reduction

$ rn report.csv
route_report_before.csv → report.csv   # only candidate

Ambiguous reduction (refused)

$ rn route.csv
Multiple candidates:
  route_report_before.csv
  route_raw.csv

Installation

cargo install rn

Or download binaries from Releases and place in your $PATH.


Why rn?

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.

About

quick inferring rename tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published