Tag Archives: rename

rename: The built-in filename sifting tool

Sorry for the one-day break; Thursdays are always a little bit hectic for me, and this being the last in the month was especially busy.

The bulk of util-linux is splashed across the previous post, but I have a few left over that I want to point out. rename is one of those, and at its best, rename is a quick and speedy tool for bulk renaming files. Here’s what it does, on a good day:


That’s a classy solution for bulk renaming where the same string needs to be substituted out in each file. rename makes it (more or less) a cinch to swap date strings, replace extensions or even make mass insertions and deletions to file names … with a little added command-line kung fu.

rename‘s shortcomings — and you knew I was going to point some out — occasionally crop up, though:


If you look closely, you’ll see that the last file name had its prefix changed, but not the extension. rename caught the first instance of “text,” but quit before it found the other.

rename also has very little in the way of error-checking. Once you send the command, the deed is done … and short of reversing your previous command, there is no preview-and-commit. And you must be cautious that your substitution doesn’t allow for files to be moved onto one another.

And it should probably go without saying that, unless you are a regex grand master, some of the more complex or subtle renaming that is possible with something like renameutils is lost on rename. Which isn’t to say it can’t be done, only to say that your success will depend on your proficiency. 😕

rename works though, and in minor substitutions it’s a breeze. And given its simplicity and straightforward arrangement, I can’t say too many bad things about it. Keep it in mind the next time you dump a couple hundred pictures off your digital camera, and need a system to order them. … 😯

mp3rename: Rename and organize, in one fell swoop

No, it is not reruns week for K.Mandla. Back in January we had a little CLI tool named mp3rename, and now again, here’s a CLI tool named mp3rename.


Two separate tools with much the same approach and results. This mp3rename, which dates back to 2003 supposedly, adds the feature of organizing the output files, in a similar fashion to mussort. I don’t recall seeing this outside of one or two other utilities.

This mp3rename is a little convoluted to work with; I found I had to call specifically for the IDv3 tag to be used, or it came up with no data to sort or rename on. That might just be my files though.

And it’s worth mentioning that the renaming options seemed to stutter if they weren’t explicitly listed in the command, even though the help flag suggests there’s a “default” string mp3rename will fall back to. I got a lot of errors until I used one I drew up with no spaces, and tacked it on to the end of the command.

If you try this in Arch, you’ll need both perl-mp3-info from extra and perl-mp3-tag out of AUR. Offhand, I’m not sure what those correspond to in Debian; my search for “perl mp3” was somewhat scattered.

In all, this mp3rename — aside from the option to organize mp3s according to artist and album — doesn’t differ a whole lot from the other one. And goodness knows there are lots of other scripts, some specific to file types, that will do the same in much the same way.

The lesson to be learned here is, if you are a young Turk in software design circles, the command-line mp3 renamer utility has been done. And done, and done, and done, and done. … 😐

rntools: An unexpected find

I have an application called “rn” in my list but I couldn’t find that anywhere. But I did find something called rntools, while I was digging around.

rntools is probably the safest, least unpredictable renaming tool I’ve seen so far. Even qmv, out of renameutils, has a few quirks that rntools manages to avoid.


For one thing, although rntools is menu-driven, there are some flag options. This is a bonus, since it means you can avoid long, boring command sequences with the menu mode, but also inject it into a script or give it quick commands to complete.

The menus cover a lot of possibilities, from simple case switches to complex search-and-replaces. And after you’ve made your selection and provided it with the info it needs, rntools will double-check that you’re getting the results you want before proceeding.

So you get the opportunity to back out, or reject your changes altogether. Nice touch.

All that is fine and dandy, but I do have a couple of small suggestions.

First of all, it’s no trick to make rntools crash, perhaps most easily by forcing it to rename files to some illegal sequence. I caused havoc just by renaming my data files to something starting with a hyphen, which the underlying rename process took to be a command-line flag.

Second, a couple of the options are a little too cautious. As you can see above, the command to cut characters out of a name asked me to confirm the title each time for each file. That’s not saving me any time if I have a hundred files to plod through, one by one.

On the whole though, rntools is a good option for safer, more meticulous file renaming on a large-scale basis. And hey, it’s got color. Can’t go wrong with that. 😉

P.S.: I only saw rntools in AUR, so Debian users might have to build it on their own. It shouldn’t be too much of a challenge. 😉

rename.pl: Many paths to the same destination

I have my own favorite renaming utility, but qmv is not the only way to get the job done.

Here’s a quick renaming script from perl-land, named — wouldn’t you know it — rename.pl.


I can’t say for certain who originally wrote the script, although the comment lines and the home page credit Larry Wall as the author. The site above is dated 2006, but they seem to give credit to a book published in 1999 as the source.

I don’t think it really matters; depending on your ability to express your renaming desires in search-and-replace strings, this might be more expedient than opening a text editor with qmv.

On the other hand, since that’s more or less the same thing that I do every time I use qmv with vim, maybe this is just a quicker approach to the same destination . 😐

mp3rename: The ubiquitous function, in its simplest form

Before I even showed you a screenshot, you would probably have an idea of what mp3rename does.


And yet I’d be leaving out a few crucial points if I said no more than that.

First, mp3rename needs you to set the “look” of the files when they’re renamed. In other words, it wants to know how the files should look when they’re done.

So running it the first time with something like this

mp3rename -s '&a - &b - &k. &t'

and then following it with

mp3rename *mp3

Should give you files that look like

Revolution Void - Increase the Dosage - 1. Invisible Walls.mp3

and that would be good enough.

As far as I can tell, there is no way to reverse the action, i.e., to fill tags based on file names. For that, you’ll need another tool.

You’ll need to ask for zero-padding, if you want it. And be careful with the -v flag for verbosity; somehow, when I used that once, all the files were written to a single one called -v.mp3. That caused some problems.

That’s about it though. I can vouch for a lot of other renaming tools for audio files, but I suppose in its simplest form, this is what the function looks like.

Oh, by the way: There are a lot of projects that go by the name “mp3rename”. This one comes out of the Debian repos and appears in AUR; the fact that it was in both is the reason I used it. There’s another one here, and some others elsewhere.

mp3info: The details, plus a little

By the looks of it, mp3info hasn’t seen any real updates in about eight years. That, of course, does not mean it is by any stretch unusable.


And if that was all mp3info did, we could call it done and move on to the next program. But take a look at this:


Hey, what’s that? An interactive id3 tag editor? And it’s got some actual visual arrangement to it?! It’s a Christmas miracle!

It is and it isn’t; mp3info’s “interactive mode” is still a bit primitive. Text editing is just arrow keys and space/delete; once you leave a line, you can’t reverse direction; once you leave a file, you can’t move back to it; there’s no mass-paste function, unless you first rely on mp3info’s existing command-line flags. I could go on.

This is a step in the right direction though. I’ve been on a quest for a proper music tag editor for the console for about a decade now — something like an EasyTag console application. And every time I get close with things like audiotag, id3ed, or lltag, or now mp3info.

Of course, if I had started to make one years ago when I first noticed this absence in the universe, it would be done now. And you wouldn’t have to suffer my complaining. 😐

dagger: A quick run over covered ground

It seems like it wasn’t long ago I took a first spin past dagger, but I guess it’s been two and a half years. Either way, I will make this quick and painless.


Suffice to say that dagger is a command-line tool to arrange and rename audio files based on their tags. It’s a clean and clever Python program that does exactly what you ask of it, and keeps your system sparse.

The home page has a prebuilt deb file if you’re using Debian or Ubuntu; what you see in the screenshot there is a Wheezy installation with vorbis-tools added so dagger can get at ogg files.

dagger’s not the console application I’ve been dreaming of for years now, but it will do the job of renaming files according to their tags.

Couple this with something like beets or lltag and you’ve got an entire suite of tools that might actually satisfy your craving for a proper console application.

It almost does for me. 🙄 😐

detox: Cleanup crew

Oddball screenshot today, from an extra extra extra machine that found its way to my house a couple of weeks ago:


Special for you, just to show off detox, because special character sets show up as plain squares on my framebuffer machine.

You’ll have to look close to see what detox actually does, but if you have sharp eyes, you’ll find it.

Special characters or international glyphs are converted to base character sets, according to rules or “sequences.”

You can designate a sequence and get specific results, in either base characters (such as française to francaise) or combinations thereof (I think æ becomes ae, for example).

As you can see above, the results are more impressive with French than with Japanese, but that’s only to be expected; I didn’t anticipate detox would wrangle with more than 50,000 characters across three alphabets. 😯

I mentioned this a few years ago, in the context that it was easier to manage files at the command line if they had been stripped of unusual characters.

I have noticed some issues with music players too, which couldn’t read the file names if they included certain extended characters. (Ahem. Audacious.) And that was only about six months ago.

So there are modern applications for this, even if most modern machines can probably display those characters just fine.

exiftool: One small gimmick

I have a list of tools that are veritable Swiss Army knives — things that can do so much that I could probably dedicate an entire week on how to use them.

On the other hand, they don’t have much of an interface, which makes them only vaguely interesting to me as console applications.

But they’re great things to have on hand. Today I’ve got exiftool to show, which is really clever if you lean toward obsessive-compulsiveness, like I do.

Let me explain. I like personal photos and wallpaper and so forth — lists of image files — to show their dimensions in their file name. I.e.,


Maybe I’m not alone on that. But without some way of pulling the dimension information from the file and appending it to the name, it becomes a hideous chore.

exiftool can do this in one fell swoop, like this:

exiftool -ext 'jpg' '-filename<%f_${ImageSize}.${FileType}' .

One command, and the entire folder gets manhandled in seconds. Change the extension as you like, or just use a splat to attack everything.

The downside, if you can call it that, is there’s nothing to show while exiftool does its thing. There’s no interface, no navigation boxes, no confirmation or onscreen help.

It just does what it’s told, and shuts up. Which is an admirable trait, I suppose. … 😐

P.S.: Bonus! Latest update only days ago! 😀