Fixing the tags for multi-disc albums (A01, A02, etc.)

Hi, I copy all my CDs to my computer and listen to them there. I recently set up a media server to stream my audio files to various devices in my house, but the media server gets confused by the way I've tagged my multi-disc albums.

Using the Beatles' White Album for example, here's how I've been naming files:

A01 Back in the USSR.flac
A02 Dear Prudence.flac
A17 Julia.flac
B01 Birthday.flac

As you can see, I use "A" and B" to indicate which disc. The media server get confused by the non-numeric characters at the start of the filenames.

Users of that media server have recommended that I use mp3tag to set valid track numbers and disc numbers for all of the files.

So, here's what I want:

A01 Back in the USSR.flac -> disc 1, track 1
A02 Dear Prudence.flac -> disc 1, track 2
B01 Birthday.flac -> disc 2, track 1

My question is: is it possible for me to get mp3tag to do this?

I have thousands of files to re-tag, and plan to continue to copy CDs to my computer using my current filename scheme (A01, A02, etc. for multi-disc sets), so I would prefer to find a way to automate the tagging rather than doing it manually.

I'm a programmer, so I don't mind writing scripts. I just wanted to know if mp3tag has the flexibility to parse those "A01" type prefixes and add appropriate track and disc numbers.



Try an action of the type "Guess value"
Source: $sub($ord($left(%track%,1)),64)==$right(%track%,2)
Pattern: %discnumber%==%track%

The Source expression relies on the CD letter to be always a capital.

Hi, I just downloaded mp3tag and tried that action. Unfortunately, it didn't work; it simply changed the Discnumber to -64.

I'm guessing that this is because the "source" script expects the "A01" to already be in the Track field, which is not the case. Currently "A01" is only present in the filename: "A01 Back in the USSR.flac".

How can the script be modified so that it extracts the first "word" of the filename, where by "word" I mean a block of characters separated by whitespace?

the I would use first the function
Format string: %track% %title%

Like that you get structured data into the fields.

Okay, thanks. If I populate the Track field first, then the Action works.

However, there are 2 changes I would like to make to the Action:

  1. If a song is in a single-CD set, the track numbers are simply numeric (01, 02, 03, 04, etc.) and as a result the Action sets the Discnumber to a negative number (-16 for tracks 01-09 and -15 for tracks 10-19). So, it looks like it's subtracting 64 from the ASCII value of the first character of the Track string ("0" or "1"). Ideally, the Action would either leave the Discnumber field blank for single-disc sets, or at least set the Disc number to "1". Is this possible?

  2. Can we omit the leading 0s from track numbers?

Ideally, "B02 Birthday.flac" would get Discnumber "2" and Track "1"
...and "01 Come Together.flac" would get Discnumber "" or "1" and Track "1".

Is this possible?

this is all different from your initial post.
And different preconditions require different solution.
You could filter for the ones that you want to treat:
%track% HAS A OR %track% HAS B

And for the others you can use
NOT %track% HAS A OR NOT %track% HAS B
and then enter the discnumber via the extended tags dialogue (ALt-T)

Is there a page which would teach me how to add preconditions to actions, so that I can try modifying the Action code?

Or even just a page which has good examples of how to parse filenames and tags in order to populate other tags, like your original Action did?

Okay, I figured out what I needed by reading the documentation on this page:

Here's my script, which parses the filename and adds both the Discnumber and Track:


This handles both single-disc and multi-disc sets.

For single-disc sets, it sets Discnumber to empty. Is it better form to leave it empty, or set Discnumber to 1 for single-disc sets?

Personal preference. I don't add discnumber to single discs, but I know others that do.

1 Like

I went through 3 or 4 major changes about tracks / discs over ~15 years

Currently I store the number of disc at the end of the ALBUM name [so that it will be shown to me via Advanced Title Formatting o Winamp]

And the TRACK field I utilize for the exact number of disc, followed by a dot, followed by the number of the track

And to answer your question: keep the 1 [by whatever means] to indicate disc 1, even if it is just a 1 disc album