Viren: Bulk-Rename Files Using Your Editor
Often I want to rename multiple files in a similar way. There are just enough files that the repetition is annoying, but not enough to bother starting a GUI bulk-renamer like krename and configuring it to do what I want. I know how to avoid repetitive work in my editor, so it would be nice if I could just rename the files from there.
I wrote a little tool called viren that enables this. When launched, viren opens an editor window with the list of files in the current directory. You can use your editor's features to change the file names. (But don't add, remove, or reorder the lines.) When you save and quit the editor, viren will rename the files as you requested.
Here is a quick demo. I have a project called crop_many
. I want to rename it
to RotateMany
, and also change the capitalization from snake_case
to
CamelCase
. I can do this quickly with viren:
To install viren, do pip install viren
.
Note that viren calls editor
internally, so it works with any editor, not
just vim. On Debian / Ubuntu, you can choose which editor to use with
update-alternatives --config editor
.