Ogg > MP3 (thanks, Apple) (not)

I have several CDs (Compact Discs, not Certificates of Deposit) of music that I like. When I popped them into my PC, I got several folders of files I could copy from. I chose to copy the .ogg files because I liked the idea of using an encoding format without weird licensing issues.

Apple has foiled that plan. If I try to play a playlist on an Apple device, the .ogg files get skipped because (apparently) Apple doesn’t feel like playing nice with the Open Source community. They may have more money than God, but adding another codec – that doesn’t have license issues – to their devices isn’t something they are going to spend money on.

When I work on-premises in the office, my co-workers are often noisy and annoying. I want to pop in my Airpods and play background music to drown out their inane chatter. I don’t want to carry the music files on my device; but I do have a Nextcloud server at home that can stream the audio from the Music app web page. I can log in on my iPhone and play the playlist.

But because it’s an iPhone, it auto-skips the Ogg Vorbis files. This doesn’t happen when I’m at home playing the same playlists on Linux or Windows.

So now I get to re-copy the files from the physical media to my NAS (network attached storage) which in this case is a Synology.

First, I get to delete the files with the .ogg file extension. Two steps (for example):

exiftool -p '$filename' -if '$album =~ /WOW Worship: Yellow \(disc 1\)/' *.ogg > wow_worship_ogg_file_list
This generates a file, wow_worship_ogg_file_list, which has the file names in a list.

then to delete them:

xargs -I{} rm -r "{}" < /path/wow_worship_ogg_file_list

Second, after having cleared out the disk space, I can copy from my physical CD to my NAS. That takes a while; and, after it is done, the file names aren’t wonderful. Rename music files to their title to the rescue.

Except, of course, for a duplicate file name. I have an MP3 file I bought from Amazon (published by Monstercat) with the same title as one of the files from the WOW Worship CD. I would prefer to rename the Monstercat file, but really if I’m going to be running the rename music files to their title command often, I need to change the Title inside the .mp3 file. If I don’t, the next time I run it, it will attempt to rename the file to a duplicate name that is already in use.

Exiftool doesn’t really write new Titles, apparently. I think it can, depending on the file type. I wonder if the weird license problems of MP3 are at the root of the problem. Whatever: the answer was to add the id3v2 program and use it instead.

id3v2 -t 'Title by Artist' file.mp3

Now the rename music files to their title script moves the one file to the new file name, and the other file to its simpler file name than what came off the CD.

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' *.mp3

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 .mp3

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 .mp3 (because we told exiftool only to look at .mp3 files).

Three Dog Night concert February 10, 2023 Visalia Fox Theater

So much fun. I am glad I went. Three Dog Night was popular when I was in elementary school: they had 21 hits in the top 40 in six years (beginning in 1969). I don’t remember the words too many of their songs, but I do remember singing along to them as a kid.

Some of the songs they did were An Old Fashioned Love Song, One (is the loneliest number), Black and White, Celebrate (dance to the music), Mama Told Me (not to come), Never Been To Spain, Liar, and of course my favorite song of theirs: Joy To The World.

The guys in the band are getting pretty old, but they did seem to be having a lot of fun.

On the one hand, I want to say it was a great show. But on the other hand, I cannot ignore that the mixing was poor. Did I have fun? Yes, definitely. Would I have enjoyed it more if I could have heard the vocals clearly? Definitely.

The band did say they are working on their first new album in twenty years; they sang a song from it. It started out a cappella, and the sound was perfect. The song was beautiful in both lyrics and sound. I’m looking forward to buying the album when it comes out.

But the fact that the vocals were perfect when the mix was a cappella, and indiscernible when instruments were mixed in makes me think it was the mixing that was the problem.

The Visalia Fox Theatre has good acoustics. It is a small enough venue that booming big box echoes aren’t a problem. The theater was packed, so nice absorption. The opening act was one guy and his acoustic guitar: he sounded great. Great singer too.

So it was pretty disappointing that during the first song, I could instantly tell that the vocals were being drowned out by the background instruments.

I enjoyed the show, and I am glad that I went. But I suspect that they would have gotten a warmer reception if we could have heard them well. I’m not trying to say they got a cool reception; they did not. But I do think everyone was hoping for better sound.

exiftool to playlist file

Assuming that you are currently in the subdirectory with music files, and those files are of type .ogg and you want to create a playlist file named _great.m3u which contains the names of the songs with “World of Warcraft” in the album name, this one liner creates such a file:

exiftool -p '$filename' -if '$album =~ /World of Warcraft/' *.ogg 2> /dev/null > _great.m3u

Assuming that you then wanted to add the files of type mp3 from the artist E.S. Posthumus, this one liner adds to that file:

exiftool -p '$filename' -if '$artist =~ /E.S. Posthumus/' *.mp3 2> /dev/null >> _great.m3u

Assuming that you then wanted to add files of type mp3 with the Genre of “Classical”, this one liner adds these to that file:

exiftool -p '$filename' -if '$genre =~ /Classical/' *.mp3 2> /dev/null >> _great.m3u

Assuming that you then wanted to add files of type mp3 with the Comment of “VIVA EL PRESIDENTE!”, this one liner adds these to that file:

exiftool -p '$filename' -if '$comment =~ /VIVA EL PRESIDENTE!/' *.mp3 2> /dev/null >> _great.m3u

exiftool is the wonderful utility written and maintained by Phil Harvey

-p '$filename' prints the file name. We later strip off the other stuff by redirecting stderr to null. That’s the 2> /dev/null part.

-if '$album =~ /World of Warcraft/' and -if '$artist =~ /E.S. Posthumus/' are matches against a regular expression. =~ says we are doing a match and the text between the slashes are what need to be present for the match to report true.

> _great.m3u overwrites the existing file, but then >> _great.m3u appends to it.

Care to guess who purchased the collector’s editions of some of the games so I could get a CD of the game music (or files from Steam)?

One thing (I don’t know that it’s a problem, really) is that Artist =~ /E.S. Posthumus/ will find the same file as Genre =~ /Classical/ so the same songs end up in the playlist twice. Maybe I just like E.S. Posthumus so much that I want their chance of being picked by the shuffler better than average. 😉

But if that’s not your bag, this will make a new file (with a new name) which contains only unique song file names:

sort _great.m3u --unique --output=_great-unique.m3u

If you happen to have your own Nextcloud with the Music Player app, you can import this _great-unique.m3u file directly into a new playlist.