Skip to content

darkone-linux/rename-simple

Repository files navigation

rename-simple

CI Rustc Version License: MIT

A small Rust CLI tool that renames files and directories to clean, ASCII-safe slugs.

rename-simple demo

What it does

  • Transliterates accented and extended Latin characters to ASCII (é → e, ç → c, œ → oe, ß → ss…)
  • Lowercases everything
  • Replaces spaces and special characters with -; collapses consecutive separators
  • Preserves _; cleans up _- and -_ sequences to _
  • Strips leading and trailing - / _ before the extension
  • Preserves known compound extensions (.tar.gz, .tar.bz2, .tar.xz, .tar.zst)
  • Keeps extensions separate only when they are ASCII alphanumeric and ≤10 characters (e.g. .tét → absorbed as -tet; .abcdefghijkl (12 chars) → absorbed as -abcdefghijkl)
  • Skips hidden files (.gitignore, .DS_Store…) and flags naming conflicts

Installation

Requires Rust 1.70+.

cargo install --path .

Usage

rename-simple [OPTIONS] [DIR]

You must specify one of -f, -d, or -a to select what to rename. Running rename-simple without any option prints this help.

Option Description
DIR Directory to process (default: current directory)
-f Rename files only
-d Rename directories only
-a, --all Rename both files and directories
-r, --recursive Process subdirectories recursively
-n, --dry-run Preview renames without touching any file
-v, --verbose Show details of each rename
-h, --help Print help
-V, --version Print version

Examples

Preview all renames (dry-run)

$ rename-simple -a --dry-run ~/Downloads
  01_ Introduction au Projet.PDF  →  01-introduction-au-projet.pdf
  Réunion d'équipe (2024).docx    →  reunion-d-equipe-2024.docx
  backup.TAR.GZ                   →  backup.tar.gz
  Café Montréal.jpg               →  cafe-montreal.jpg
  à faire .tét                    →  a-faire-tet
  notes.cuicuicuicui              →  notes-cuicuicuicui

Rename files only

$ rename-simple -f ~/Downloads

Directories are left untouched; only files are renamed.

Rename directories only

$ rename-simple -d ~/Projects

Files are left untouched; only directories are renamed.

Rename everything

$ rename-simple -a ~/Downloads

Recursive processing

$ rename-simple -a --recursive ~/Documents

Renames files and directories at every level of the tree.

Verbose output

$ rename-simple -a -v ~/Downloads
Directory: /home/user/Downloads

  01_ Introduction au Projet.PDF  →  01-introduction-au-projet.pdf
  Réunion d'équipe (2024).docx    →  reunion-d-equipe-2024.docx
  Café Montreal.jpg               →  cafe-montreal.jpg

3 entry/entries renamed, 0 error(s).

Tips

If you use -a most of the time, a shell alias saves a few keystrokes:

alias rsa='rename-simple -a'

Add this line to your ~/.bashrc or ~/.zshrc, then:

rsa ~/Downloads          # rename everything
rsa -r ~/Documents       # rename everything, recursively
rsa -n ~/Downloads       # dry-run preview

Running the tests

cargo test

License

MIT

About

Rename file names using the most relevant lowercase ASCII characters

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages