Sunday, December 23, 2012

batch renaming

There are various ways to rename a bunch of files in Linux. Some approaches are mentioned in the Linuxaria article "Mass renaming files on Linux."

That article mentions the rename and mmv commands; a method using bash with the mv and basename commands; and, GUI apps such as Midnight Commander, Thunar, KRename, and GPRename.

In Debian Wheezy, I found the rename command, and I found mmv in the repos. For batch renaming, however I prefer a GUI tool.

I've used Thunar in Xfce for batch renaming, and it works just fine. It's also quite easy to install in other desktop environments.

I've also used KRename in KDE. One approach is to enable KRename in KDE's Krusader file manager.

In current KDE versions, though, the Dolphin file manager (which is not mentioned in the article) handles batch renaming quite well. Simply select the list of files you want to rename, right-click, and click on "Rename..." The resulting dialog box is self-explanatory:



I have Dolphin installed even in my non-KDE systems because it's my favorite file manager for working with photos; so, I normally choose Dolphin for doing any batch renaming. Thunar is perfect for Xfce, though; and for GNOME, GPRename does the job. Here's a screen shot:



As you can see, GPRename shows a preview of the changes before they're committed. I found GPRename available in the Wheezy repos.

The article also mentions Midnight Commander, which I also found in the Wheezy repos. Old-timers will be quite familiar with mc, but others might need to familiarize themselves with it. I installed it and took a shot at a batch renaming exercise.

I navigated to my test directory and selected the files by pressing + and typing in testing*, then pressing Enter.



With the files selected, I used the Rename/Move option under the File menu.



Then I renamed the files by using testing* for the source and test* for the destination.



The result:

steve[~/test]$ ls
test1  test2  test3


There's also a Batch Rename plugin available for the SpaceFM file manager, for another GUI approach that isn't DE-specific. But as of this writing, I haven't been able to get it to work, even after examining this Crunchbang forums thread. Not sure what I'm doing wrong, but I gave up on it for now since I have so many other ways to do batch renaming besides trying to do it with SpaceFM.

No comments: