File Renaming with total disc number

I used Musicbrainz Picard to autotag a bunch of mp3 albums. However, I noticed that picard updates discnumber and totaldiscs even for single disc albums. So I now have a bunch of single disc albums that have discnumber=1 and totaldisc=1. I want to rename files to include discnumber before track number if totaldisc > 1 (e.g. 1-02 title.mp3). But if the totaldisc = 1 or is blank, then just track number without totaldisc number (e,g, 02 title.mp3). I don't want to rename single disc files with 1-02 title.mp3 so as to distinguish from multidisk albums. I don't want to have to remove discnumber and totaldisc number tags manually just so I can get the naming convention to work the way I want. So, long story short, is there a way to have mp3tag script or regex that says, if totaldisc>1, then discnumber-track title; otherwise just track title? If so, can you provide the coding to include step by step instructions as to how and where to enter the code or script in mp3tag? I like how picard can autotag a bunch of albums at one time; but I really wish it didn't add discnumber tag to single album discs. Appreciate any help you all can provide/

Isn't it possible to configure the Picard tagger, which tag fields should be written?
Mp3tag can remove tag fields, which you do not want to be stored.

Formatstring: $ifgreater(%TOTALDISCS%,1,%DISCNUMBER%'-',)$num(%TRACK%,2)' '%TITLE%

Apply the formatstring in ...
Mp3tag Convert "Tag - Filename"
... or ...
Mp3tag Convert "Tag - Tag" on field _FILENAME
...or ...
Action "Format value" on field _FILENAME


Edit: beaten by Detlev :slight_smile:

I use this for my own filename formatting.

$ifgreater(%totaldiscs%,1,Disc $num(%discnumber%,2) - ,)

Use the above function within your existing filename formatting. If you don't have one set up already:

  1. Open Actions Menu>Actions.

  2. Click the 'New' button and enter a name for your filename formatting action.

  3. Click the 'New' button in the newly opened window to create an action type.

  4. Select 'Format value' from the dropdown menu.

  5. In the 'Field' text box enter:


  6. In the 'Format string' text box enter the desired filename format, such as given below.

  7. Click OK on all the Action windows and apply the Action group.

Here's an example of the $ifgreater() function used in a full filename format:

[%artist% - ][%album% - ]$ifgreater(%totaldiscs%,1,Disc $num(%discnumber%,2) - ,)$if(%track%,$num(%track%,2) - ,)[%title%]

Which for multi-disc albums would output to: Stevie Wonder - Songs In the Key of Life - Disc 01 - 01 - Love's In Need of Love Today.flac, and for single disc albums omit the 'Disc 01 - ' section.

The tags in the square brackets tell Mp3Tag to only output that tag if it exists. I like to separate tags with hyphens and format track and disc numbers with a leading zero by using the $num() function, but that can easily be changed.

Thanks, Detlev and Lauren, this is exactly what I wanted. I just realized another problem I neeed to work on with tags; some of my albums have discnumber but not totaldisc number so I need to see if there's a way to say "if totaldisc>1 OR discnumber>1, then discnumber-title.mp3. Where can I learn to more about how to use the conditional statements or functions like this one for myself (e.g. if, greater than and or)? Anyways, thanks again because this is a huge help.

If tagfield TOTALDISCS exists, then use it, otherwise use tagfield DISCNUMBER.

$ifgreater($if2(%TOTALDISCS%,%DISCNUMBER%),1,%DISCNUMBER%'-',)$num(%TRACK%,2)' '%TITLE%