RegEx Script to Mimic Naming Rules Used In Magic MP3 Tagger

Hello Music Fans,

Am new to the MusicBrainz commuity, just joined and donated. I am an IT Professional of 25 years with a bit of exposure to music in various forms during my life and have an appreciation for it. But, I am new to what I am doing with audio/music files. As in my other areas of IT, I prefer order with my data and files. Hence, MusicBrainz will appear to be a new welcoming home for me.

One area I am very particular about is file naming conventions. Do it right and all files sort into a nice neat orderly fashion by name. Magic MP3 Tagger has some fairly easy to understand UI options to define rules for renaming files, so there will be order in my music universe/libraries residing on my computer(s). I have had experience with regex with other systems, but Foobar2000 is a bit different. Also, it has been quite a while, since I last used regex scripting language. I want to use the below format and rules which are mostly the same used/available in Magic MP3 Tagger.

Filename = [Artist - Album - Track Nbr - Title].fileextension

• Space formatting [no multiple spaces, no spaces at the beginning and the end, insert spaces before brackets…]
• Handle bracket Close when open
• Format track number with leading zero
• Use sortable artist names like “Offspring, The”
• Include featuring artist
• First letter: Upper case
• Following letters: Don’t change (want to prevent AC/DC or ACDC changing to Ac/Dc or AcDc)
• Apply to: Every word
• Skip missing tags

So, can my above rules be done with the regex. But, I’m struggling to figure out the Foobar2000 RegEx language. Is there any more documentation out there to help me create those strings or has someone already written them and shared them. I did check the forum before starting this topic.

Where’s the option in MusicBrainz to put all music files from a source with many subdirectories into/under a single directory? Did I miss the option/setting somewhere? Magic MP3 Tagger has it. Or, am I to assume that needs to also be defined by regex scripts in MusicBrainz?

I would like to hear what people think about using the artist name “FirstName LastName” versus “LastName, FirstName”. What are the pros and cons to having these different formats in the file name. I would think “FirstName LastName” is most appropriate, because and artist name as first then last is a proper noun as opposed to the other format.

Sorry for the long topic intro. Spent a couple of days researching this. Unfortunately, RegEx is not my best language. Did a search to see if someone has already wrote a script already but nothing close. Just need a small Rosetta Stone.

Let’s do it step by step The first step would be to just write the above into the file naming script in Options > File Naming, but use the proper tag variables:

%artist% - %album% - %tracknumber% - %title%

The extension is added by Picard automatically, no need to do this in the script. Now for the artist you want it to be sortable. The easiest solution would be to use %artistsort% instead of %artist%. This would give you “Offspring, The”, but aso “Jackson, Michael”. I’m not sure what you want exactly, but if you want to keep the name as is but only move something like “The” to the end, then try the $swapprefix function:

$swapprefix(%artist%) - %album% - %tracknumber% - %title%

For the tracknumber you want it with leading zero, use $num(%tracknumber%,2) to get it with two decimals and leading zero:

$swapprefix(%artist%) - %album% - $num(%tracknumber%,2) - %title%

You want missing values to be skipped. Actually the above should in most cases be available. But if you really want to e.g. react to when %album% is not available use something like $if(%album%, - %album%). This will output the album name including the " - " before it only if album is set.

Under Options > File Naming you can select “Move files when saving” and then set a destination directory. I assume you would also like to create a hierarchy of subdirectories then. You did not mention it, but let’s assume you want to create a directory for artist and album extend the above script as follows:

%albumartist%/%album%/$swapprefix(%artist%) - %album% - %tracknumber% - %title%

A slash is the directory separator in the script. If “Move files” is enabled Picard will create the directories as needed in the destination directory. Also note how I use %albumartist% here to get consistent directory names. Just using %artist% woul eventually scatter the files for a single album around if the different tracks have different artists (e.g. on compilations, guest tracks on albums or different featuring artists).

You choose what works best for you. Sorting by last name first is how you usually would find people in any directory, e.g. phone book or looking for authors in a library. If you are more used to this and you would look for “Jackson, Michael” first, use this. If you are more used to find him under “M”, use this.

UPDATE: Just a side note, because this gets mixed up so much: You ask about “where is the option in MusicBrainz” and I silently assumed you are talking about MusicBrainz Picard. But there is a distinction between MusicBrainz, the database and website, and MusicBrainz Picard, which is the tagger software. While Picard is the tagger developed officially as part of the MusicBrainz project, it is not the only tagger supporting MusicBrainz data and there are other alternatives you can choose from if you want to.

4 Likes