Rename your files in a text editor
Sometimes you want to rename a bunch of files. Using your typical file manager would be too slow. A better way is to hand the task off to your favorite text editor. A number of programs do exactly that. They work like this:
- You enter a directory.
- You run the command.
- You edit the filenames as text in your text editor.
- You exit the editor and the program renames the files.
This is simple, and simple is good! Really the only hitch is keeping straight all the software choices. So here's an opinionated list.
Ones I like
emv is a single file perl script that lets you use any editor to rename files. The interface was cluttered -- the editor displays a ton of text before the filenames -- and on exit there was a warning about using a more suitable shell (this is on OpenBSD 6.9 with ksh). But I might use it since it does the job and it's a single file that can live in my
~/bin
directory. Screenshot of emv.mvedit is an old perl script that "lets you edit the output of recursive directory listing (same as with ls -1aR) and thus rename a great number of files in a convenient fashion." It's really good. The interface is just a list of the files in the directory. No numbers, no columns. After exiting the editor but before files are renamed, you will get a prompt that lets you preview and approve or deny the changes. The only downside is that this program was last updated in 2006. Runs out of the box on OpenBSD. This is the one I'll use. Screenshot of mvedit.
qmv is "quick move," packaged as part of renameutils on Debian (OpenBSD has no package). renameutils comes with just five small utilities related to renaming files. The package seems to have fewer dependencies than moreutils. By default, qmv shows filenames in two columns: both columns start with the original name, but it is the right column you edit with the new filenames. This is a mixed bag. It's nice to have the before and after at a glance, but needing to keep intact the original filename makes it hard to search and replace. But there is
qmv --format=destination-only
-- this will show only the current/future name. Screenshot of qmv.vidir lets you "edit a directory in your text editor." It is part of Joey Hess's well-known moreutils package, available on Debian and OpenBSD. A downside is that it comes with 14 other mostly unrelated programs. But there are big upsides: Hess has a long history as a FOSS developer and moreutils is updated often. vidir has a clean, simple interface: a numbered list of filenames. Just change the names. Screenshot of vidir.
Ones I didn't try
dir-edit is a python3 script. It seems pretty good, but if I'm going to use a stand alone script that I get from outside a repository, I'd prefer it to be in shell or perl. Those will work out of the box on OpenBSD.
mvedit -- no relation to the above mvedit -- is a bash script. I skipped this one since I don't have bash installed (remember, bash is not synonymous with the command line).
renamer.vim is a vim plugin. I normally use vi, not vim, so I also skipped this one. But if this runs on any platform that can run vim, this is a nice approach.
vimv is a bash script that "Lists the current directory's files in Vim, so you can edit it and save to rename them." See comment about bash above.
viren is a python2 script that can work in any editor. I did not try it because python2 is a dead end.
A final word
Your files are important. Please read the documentation before using any of these. Some of the programs have limitations. Most of them give you the power to delete files. You don't want to make a mistake. Read the documentation.