Reset track number in filename for new disc


I would like to separate the logical view of a multi-disc album from the physical view. Because of that the Track field should use all tracks from all discs: the first track from the first disc would be 01/28 and the last track of the second disc would be 28/28 in case both discs have 14 tracks. I managed to get this with the auto-numbering wizard without any problem.

Now I would like to keep the physical view for the file names, so the first track from the first disc is called [1] 01 - title - artist and the first track of the second disc should be [2] 01 - title - artist and the last track of the second album should be [2] 14 - title - artist.
My current rename format is
['['$num(%discnumber%,2)']'] $num(%track%,2) - %title% - %artist%

So how can I get the track number being reset for each additional disc?



In this case you have to apply a different sequence of steps, at first physical, then logical.

  1. Renumber the tagfield TRACK for each disc separately.
  2. Rename the filenames using DISCNUMBER and TRACK.
  3. Renumber the tagfield TRACK for the entire group of discs.


Thanks for the idea. This would probably work but would work only one time.
So in case I would like to batch-rename my collection (for example to add the album name) I could not do this with this approach. Isn't their any other chance? Or could mp3tag maybe get another 'virtual' field like %track_of_disc%?


As you say you can add a self-defined tag-field for this purpose and using it for naming the files.

Just a warning:
In case of self-defined tag-fields don't edit your tags with the windows-explorer. I noticed some side-effects doing this and tag corruption.

The proposed algorithm works for each new case. Once the algorithm has been done, there is no need to do it again on the same set of files.

As long as you do not change the propper filled fields DISCNUMBER, TRACK, _FILENAME ...
you can change other tag-fields as needed.
To be safe for the future you may create one or more helper tagfields, e. g. create a tagfield TRACK_ORIG to store the original physical tracknumber.

You may set up tagfields as you need it, but do not use reserved fieldnames.


First of all, thanks for your ideas I really appreciate that.

Probably is DISCTRACK the way to go. Because as far as I can see it this is the only way to be able to rename files again with a slightly different scheme.

[5 minutes later] I tried this approach and its working very nice. The only remaining issue is now that I would like to have a ternary expression like hasvalue(%disctrack%) ? %disctrack% : %track% for the rename operation to avoid having to copy %track% to %disctrack% for single-disc albums as well.
Any chance to accomplish that?

[10 minutes later] Ok, found it myself. In case someone is interested, my resulting rename format is ['['$num(%discnumber%,2)']' - ]$iflonger(%disctrack%,0,$num(%disctrack%,2),$num(%track%,2)) - %title% - %artist%


$if(%DISCTRACK%,'then','else') _FILENAME <== $if(%disctrack%,['['$num(%DISCNUMBER%,2)'] - ']$num(%DISCTRACK%,2)' - '%TITLE%' - '%ARTIST%,%_filename%) _FILENAME <== ['['$num(%DISCNUMBER%,2)'] - ']$num($if2(%DISCTRACK%,%TRACK%),2)' - '%TITLE%' - '%ARTIST%