Rename audio files to just their titles

Another exiftool operation: suppose you have a bunch of files named something like this:

01 - String Quartet in B flat Major, 1st movement "Allegro".ogg
02 - Sonata, K. 310, 1st Movement (Mozart - Alfred Brendel).ogg
03 - Asturias_Leyenda (Albeniz - Alirio Diaz).ogg
04 - Massenet: Meditation from Thais (Mischa Elman).ogg
05 - La Coulicam - Rondement (Rameau - Harnoncourt, Lars Fryden).ogg

11 - Sonatine en trio "Modere" (Ravel - Orpheus Trio).ogg
12 - Preludes - La cathedral engloutie (Debussy - Sviatoslav Richter).ogg
13 - Eili, Eili (Mischa Elman).ogg
14 - Simple Fugue (Gr. 1, D. 1) (Bach - Gustav Leonhardt).ogg
15 - A Felicidade from Black Orpheus (Paula Robison).ogg

But really, you want the files to just be named after the Title of the song. You don’t want the leading track number, and if there are any characters in the file name that would cause Windows heartburn (like slashes, colon, asterisk, question mark, etc.), you would like those stripped out too. For example: Massenet Meditation from Thais (Mischa Elman).ogg

Here’s a handy command:

exiftool '-Filename<${Title;}.%le' *.ogg

So we have exiftool which is the utility that does the work. Thank you to Phil Harvey for doing the work to make this easy.

Then we have two parameters:



The second parameter says to work on files with the filename extension of .ogg

The first parameter breaks down like this:


Note that the non-change-making version is -Testname< (for testing, obviously)

-Filename tells exiftool that it will be updating the file name. The < symbol says that the replacement for the file name will be incoming from the rest of the parameter.

What follows after the < has two pieces: ${Title;} and .%le

${Title;} is the processed text from the metadata variable Title. The leading $ and the { and } with the ; before the closing curly brace serve to strip out any invalid characters found in the title that wouldn’t work as a file name.

.%le appends a file name extension. Technically, .%e is the file name extension, but adding the l makes it lowercase. So we get the Title as the first part of the file name, and the last part of the file name is .ogg (because we told exiftool only to look at .ogg files).

Leave a Reply