Rename files and directories to a naming convention. Go port of stdrename. Built for Linux; it also runs on macOS and Windows, with weaker guarantees (see Behaviour).
go install github.com/ruandre/casemv@latest
casemv [convention] [target] [flags]| Name | My FILE name-2 becomes |
|---|---|
camel |
myFileName2 |
kebab |
my-file-name-2 |
lower |
my file name-2 |
pascal |
MyFileName2 |
screaming |
MY_FILE_NAME_2 |
sentence |
My file name 2 |
snake |
my_file_name_2 |
title |
My File Name 2 |
train |
My-File-Name-2 |
Words split on separators, case humps, and acronyms (XMLHttpRequest →
xml http request). lower only lowercases.
| Flag | Effect |
|---|---|
-r, --recursive |
Descend into subdirectories |
-D, --dir |
Rename directories too |
-H, --hidden |
Include dot-prefixed entries |
-e, --exclude |
Skip glob matches and their subtrees; repeat |
-n, --dry-run |
Print plan, change nothing |
-q, --quiet |
No output |
-x, --lower-ext |
Lowercase file extensions too |
-c, --convention |
Convention when none is given as an argument |
--text |
Convert stdin lines to stdout |
--config |
Config file path |
-h, --help and -v, --version print help and the version.
Exclude patterns use path.Match, anchored as in .gitignore. A leading or
inner slash matches the path relative to the target (/*.txt, docs/old);
otherwise the base name at any depth. A trailing slash matches directories only
(node_modules/). * stays within one path segment; ** is an error, and !
negates nothing.
casemv snake ./docs -r -D # whole tree, directories too
casemv pascal ./src -n -e '*.min.js' # preview, skip minified files
casemv kebab . -x # My File.TXT → my-file.txt
echo 'My File' | casemv kebab --text # my-file- Extensions are kept verbatim:
My File.TXT→my-file.TXT, ormy-file.txtwith--lower-ext. Directories have no extension:1. Something→1-something. - Leading dots are kept:
.My Notes.TXT→.my-notes.TXT. Names with no word characters (___.txt) stay as they are. Invalid UTF-8 bytes are kept. - Symlinks are renamed as files and never followed, even with
-D:Link Dir.v2→link-dir.v2. A trailing-slash exclude does not match them. --textconverts each line whole, with none of these rules:My File.TXT→my-file-txt,.env→env, and___→ an empty line.- Nothing is lost.
- Collisions abort before any rename. This covers entries that keep their names, and names that differ only in case on case-folding filesystems. A new name longer than 255 characters aborts the same way.
- Each rename stays inside the target. On Linux it refuses symlinks on the
way and uses
RENAME_NOREPLACE. Off Linux, and on Linux filesystems withoutRENAME_NOREPLACE, casemv checks the target, then renames, so a change racing between the two can still replace an entry. Off Linux it can also redirect the rename through a symlink.
- Renames run deepest-first, so a directory is renamed after its contents.
- Exit status is 0 on success, 1 on any error, and 130 when SIGINT, SIGTERM or SIGHUP stops the run, which happens between renames.
- Progress prints each rename after it succeeds. Names that hold control
characters or invalid UTF-8 print quoted. If stdout closes early, as with
| head, the renames still finish, then casemv reports the write error.
Order: flags, then CASEMV_<FLAG> environment variables (e.g.
CASEMV_DRY_RUN), then the config file: --config, else CASEMV_CONFIG, else
casemv/casemv.yaml in the user config directory: $XDG_CONFIG_HOME or
~/.config on Linux, ~/Library/Application Support on macOS, %AppData% on
Windows. No other file name or format is read, and the working directory is
never searched.
Every flag except --text has a CASEMV_<FLAG> variable, and every one except
--text and --config has a config key: --text is command line only.
Unknown keys and mistyped values are errors. CASEMV_EXCLUDE separates
patterns like PATH: with :, or ; on Windows.
convention: kebab # then a bare `casemv` or `casemv ./docs` converts to kebab
lower-ext: true
recursive: true
exclude: ["*.min.js", node_modules]A convention given as an argument overrides the default. A lone argument naming
a convention is the convention, anything else is the target, so a directory
named like a convention needs a path: casemv ./kebab. An empty argument is an
error, so casemv kebab "$DIR" with DIR unset renames nothing.
casemv completion bash > ~/.local/share/bash-completion/completions/casemv # needs bash-completion
casemv completion zsh > "${fpath[1]}/_casemv"
casemv completion fish > ~/.config/fish/completions/casemv.fish
casemv completion powershell >> $PROFILEThe first argument completes conventions, plus directories when a default
convention is set. Fish gets casemv's own script, which filters directories and
--config files the way bash and zsh do. A directory named completion needs a
path: casemv ./completion.
mise pins tools and runs tasks; hk runs git hooks.
mise trust && mise run setup # tools, Go modules, hooks
mise tasks # list all tasks| Task | Runs |
|---|---|
check / fix |
All hk checks / fixes |
test [-- flags], test-race |
Unit and CLI tests |
test-e2e |
Built binary against real trees |
test-docker |
All suites in a no-network container |
vet-cross |
go vet for darwin and windows |
ci |
check, vet-cross, vuln, every test suite |
fuzz [target] [duration], bench, cover |
Fuzzing, benchmarks, coverage |
vuln, build, install |
govulncheck, bin/casemv, ~/.local/bin |
- Hooks:
pre-commitapplies fixes;pre-pushrunstest-race. - CI: runs
check,vet-cross,vuln,test-race, andtest-e2eon Linux, and the unit and CLI tests on macOS and Windows. - Lint:
.golangci.ymlenables all linters; each disabled one has a reason.depguardlimits imports to its allowlist. - Case-folding tests: these run on a
casefoldtmpfs insideunshare -rm, which needs Linux 6.13+. Elsewhere they skip.
Copyright (C) 2026 Ruandré Janse van Rensburg. Port of stdrename, copyright Gabriel Lacroix.
GPL-3.0-or-later, the same as stdrename.