TOTALDISCS / DISCNUMBER differences Foobar2000 and MP3tag

TIL that I've been ignoring the id3 spec for decades by using DISCTOTAL instead of TOTALDISCS and TRACKTOTAL instead of TOTALTRACKS and always splitting the values of TRACK and DISCNUMBER, regardless of the format. :sweat_smile:

Anyhow: if you do want to populate the TOTALDISCS value I have an action that achieves that.
Action Type: Format value
Field:

TOTALDISCS

Format string:

$if2(%TOTALDISCS%,$if($neql(%DISCNUMBER%,$regexp(%DISCNUMBER%,^\d{1','3}\/(\d{1','3})$,$1)),$regexp(%DISCNUMBER%,^\d{1','3}\/(\d{1','3})$,$1),%TOTALDISCS%))

This leaves TOTALDISCS alone if it's already populated and only populates it with the part behind the slash of DISCNUMBER. You can easily adjust it to do the same for TRACK and TOTALTRACKS.

If you (like I did unknowingly) want to go against spec you can also add a second action
Action Type: Format value
Field:

DISCNUMBER

Format string:

$num(%DISCNUMBER%,1)

That would remove the part after the slash and the slash and also remove zero padding.

Example:
DISCNUMBER = 3/4
TOTALDISCS unpopulated

Would become:
DISCNUMBER = 3
TOTALDISCS = 4
after running these two actions. Which in case of mp3 files would go against spec by storing the DISCNUMBER in the appropriate frame and the TOTALDISCS as TXXX.