Auto number tracks with or without leading zeroes, depending on track number in album

I use MP3Tag for ~3 years for tagging my FLAC and MP3 collection and really like the software... think I have even donated :wink: I mainly use the software for maintain my CD-ripped tracks in both formats, mostly converted using fre:ac software. I use and have some overall knowledge of actions, conversions and auto-numbering tool.

For track numbering, I've chosen such a convention - if the album contains 1 to 9 tracks, do not use leading zero, and if the number of tracks is greater, use it for tracks 1 to 9. The question is, can I set MP3tag to automatically detect # of tracks in album and add or not leading zero according to that?

If the solution is not super straightforward, I don't require definite step by step answer, leading me to a specific tools will be enough. I know basics of command lines and I use regex daily.

Many thanks in advance for any help :slight_smile:

PS this is off-topic a bit, bu if someone knows how to set it in fre:ac, I'd be also glad for an advice :slight_smile:

As MP3tag does not know anything about albums, you have to help MP3tag a little to guess the total number of tracks of an album.
The easiest way would be to number the tracks with the track numbering assistant and include the total number. THis would lead to track numbers like
You could now strip the total on the right of the slash and see how long that string is.
For those albums with less then 10 tracks, the $len() function would return 1
for albums with 10 to 99 tracks it would be 2
and for albums with more than 99 it would be 3.
So you could now use $num(%track%,$len(totals))
(this is not proper syntax. The more tricky part would be to extract the totals at the end - which could be done with a "guess value" action and a user-defined field or $mid(%track%,$strstr(%track%,'/'),$len(%track%)) or whatever seems suitable.
Sometimes even the track numbering assistant is the most straightforward approach.

Extracting the total number can be done via the synthetic field %_total% (for track numbers in #/## format).

1 Like