A command line utility for batch-renaming files.
This command line utility lets you batch-rename files from the comfort of your favourite text editor. You specify the files to be renamed as arguments, e.g.
$ vimv *.mp3
The list of files will be opened in the editor specified by the
$EDITOR environment variable, one filename per line. Edit the list, save, and exit. The files will be renamed to the edited filenames.
Vimv is written in Rust — if you have a Rust compiler available you can install it directly from the package index using
$ cargo install vimv
vimv --help to view the command line help:
Usage: vimv [files] This utility lets you batch rename files using a text editor. Files to be renamed should be supplied as a list of command-line arguments, e.g. $ vimv *.mp3 The list of files will be opened in the editor specified by the $EDITOR environment variable, one filename per line. Edit the list, save, and exit. The files will be renamed to the edited filenames. Directories along the path will be created as required. Vimv supports cycle-renaming. You can safely rename A to B, B to C, and C to A in a single operation. Use the --force flag to overwrite existing files that aren't part of a renaming cycle. (Existing directories are never overwritten. If you attempt to overwrite a directory the program will exit with an error message and a non-zero status code.) You can delete a file by 'renaming' it to a blank line, but only if the --delete flag has been specified. Deleted files are moved to the system's trash/recycle bin, unless the --git flag has been specified and the file is being tracked by git in which case 'git rm' is used to delete the file. Arguments: [files] List of files to rename. Options: -e, --editor <name> Specify the editor to use. Flags: -d, --delete Enable file deletion. -f, --force Overwrite existing files. -g, --git Use 'git mv' to move, 'git rm' to delete. -h, --help Print this help text. -q, --quiet Only report errors. -v, --version Print the version number.
Vimv simply ignores any filenames that haven't been changed so you don't have to be overly fussy about specifying its input. You can run:
$ vimv *
to get a full listing of a directory's contents, change just the items you want, and Vimv will ignore the rest.
If you want to use a graphical editor like VS Code or Sublime Text instead of a terminal editor like Vim then (depending on your operating system) you may need to add a 'wait' flag to the
$EDITOR variable to force the editor to block, e.g.
EDITOR="code -w" # for VS Code EDITOR="subl -w" # for Sublime Text EDITOR="atom -w" # for Atom
The same flag can be used with the
--editor option, e.g.
$ vimv *.mp3 --editor "code -w"
Vimv is released under an MIT license.