Batch rename files and folders.
Note that this project is a Go implementation of 75lb/renamer and most of the README contents are copied from the original repository.
$ go get github.com/ryym/rnm/cmd/rnm
$ rnm [options] <files>
The find string, or regular expression when --regex
is set. If not set, the whole filename will be replaced.
The replace string. With --regex
set, --replace
can reference parenthesised substrings from --find
with $1, $2, $3 etc. If omitted, defaults to a blank
When set, --find is intepreted as a regular expression.
Used for test runs. Set this to do everything but rename the file.
Don't forget to test your rename first using --dry-run
!
Some real-world examples.
Windows users: the single-quotation marks used in the example commands below are for bash (Mac/Linux) users, please replace these with double-quotation marks on Windows.
$ rnm --find '[bad]' --replace '[good]' *
Before | After |
---|---|
|
|
$ rnm --find 'Season 1 - ' *
Before | After |
---|---|
|
|
$ rnm --regex --find '.*_(\d+)_.*' --replace 'Video $1.mp4' *
Before | After |
---|---|
|
|
$ rnm --regex --find '(data\d)(\.\w+)' --replace '$1 (checked by Lloyd)$2' *
Before | After |
---|---|
|
|
$ rnm --find 'pic' --replace 'photo' '**/*'
Before | After |
---|---|
|
|
$ rnm --regex --find '^' --replace 'good-' '**/*'
Before | After |
---|---|
|
|