renamer
Batch rename filenames.
Install
Install node then:
$ npm install -g renamer
Linux/Mac users may need to run the above with sudo
Usage
$ renamer [--find <pattern>] [--replace <string>] [--dry-run] [--regex] <files>
-f, --find The find string, or regular expression when --regex is set.
If not set, the whole filename will be replaced.
-r, --replace The replace string. With --regex set, --replace can reference
parenthesised substrings from --find with $1, $2, $3 etc.
If omitted, defaults to a blank string. The special token
'{{index}}' will insert an incrementing number per file
processed.
-e, --regex When set, --find is intepreted as a regular expression.
-d, --dry-run Used for test runs. Set to do everything but rename the file.
-h, --help Print usage instructions.
For more information on Regular Expressions, see this useful guide.
Don't forget to test your rename first using --dry-run
!
Examples
Simple replace
$ tree -N
.
├── A poem [bad].txt
├── A story [bad].txt
$ renamer --find '[bad]' --replace '[good]' *
$ tree -N
.
├── A poem [good].txt
├── A story [good].txt
Strip out unwanted text:
$ tree -N
.
├── Season 1 - Some crappy episode.mp4
├── Season 1 - Load of bollocks.mp4
$ renamer --find 'Season 1 - ' *
$ tree -N
.
├── Some crappy episode.mp4
├── Load of bollocks.mp4
Simple filename cleanup:
$ tree
.
├── [ag]_Annoying_filename_-_3_[38881CD1].mp4
├── [ag]_Annoying_filename_-_34_[38881CD1].mp4
├── [ag]_Annoying_filename_-_53_[38881CD1].mp4
$ renamer --regex --find '.*_(\d+)_.*' --replace 'Video $1.mp4' *
$ tree
.
├── Video 3.mp4
├── Video 34.mp4
├── Video 53.mp4
Give your images a new numbering scheme:
$ tree
.
├── IMG_5776.JPG
├── IMG_5777.JPG
├── IMG_5778.JPG
$ renamer --replace 'Image{{index}}.jpg' *
$ tree
.
├── Image1.jpg
├── Image2.jpg
├── Image3.jpg
do something about all those full stops:
$ tree
.
├── loads.of.full.stops.every.where.jpeg
├── loads.of.full.stops.every.where.mp4
$ renamer --regex --find '\.(?!\w+$)' --replace ' ' *
$ tree
.
├── loads of full stops every where.jpeg
├── loads of full stops every where.mp4
if not already done, add your name to a load of files:
$ tree
.
├── data1.csv
├── data2 (checked by Lloyd).csv
├── data3.xls
$ renamer --regex --find '(data\d)(\.\w+)' --replace '$1 (checked by Lloyd)$2' *
$ tree
.
├── data1 (checked by Lloyd).csv
├── data2 (checked by Lloyd).csv
├── data3 (checked by Lloyd).xls