Hello,
I just started using Picard last night to standardize my library. I have been able to successfully write my file naming script to be exactly as I want with the documentation, but am struggling with the tag scripts. I am not trying to do anything special, but fix a few things to be as I am use to them.
- Change instances of (feat.) to (Feat.)
- Change totaltracks to the value of absolutetracks (for multi disc albums).
- Add padding to tracknumber, discnumber, totaltracks, and totaldiscs (e.g. change tracknumber: 1 to tracknumber: 01).
I looked at the documentation and some posts here and came out with the following.
## Replace all instances of Song (feat.)... with
## Song (Feat.)...
$replace(feat.,%title%,Feat.)
## Change TotalTracks to AbsoluteTracks.
$set(%totaltracks%,$trim($num(%_absolutetracknumber%,2)))
## Pad TrackNumber.
$set(%tracknumber%,$trim($num(%tracknumber%,2)))
$set(%totaltracks%,$trim($num(%totaltracks%,2)))
$set(%discnumber%,$trim($num(%discnumber%,2)))
$set(%totaldiscs%,$trim($num(%totaldiscs%,2)))
This seems to do nothing. Did I miss something? Are variables set differently in tag scripts?
For setting a variable you just use the variable name without surrounding percentage signs:
$set(tracknumber,$trim($num(%tracknumber%,2)))
The %...% syntax is shorthand for $get(...) and reads the value of a variable. So when you do $set(%tracknumber%,...) you set a variable with the name of whatever value tracknumber has at the time (e.g. 1).
A short side note about padding the track/disc numbers: This won’t always work as you expect. By definition those are supposed to be numbers, not strings. For MP4 it is even technically an integer value, so any padding zeros won’t be preserved. In other formats the track numbers are technically stored as strings, so the leading zeros will be in the files. But whether the player displays them as is or is treating the loaded numbers as integers is up to the player, and other editing software might save the tags with leading zeros removed.
2 Likes
I missed that one: This won’t work for two reasons:
- The parameters are wrongly ordered. The first is the string in which something should be replaced, the second is what to replace and the third the replacement. So this should be
$replace(%title%,feat.,Feat.) (replacing “feat.” inside the title with “Feat.”).
- While this does do the replacement, nothing happens with the result. You have to set it to some variable. Likely you wanted:
$set(title,$replace(%title%,feat.,Feat.))
2 Likes
Thank you so much for the help! It seems I was indeed mistaken with a lot of the documentation I read as even I misused certain variables. On the note of padding, what do you recommend? Should I avoid doing so? I have a massive collection of mostly just FLAC and MP3 and am only just know starting to clean them up. As someone with more experience do you recommend to ditch padding and just keep it as is?
I personally won’t bother with padding the disc numbers, I see this as the task of the player to handle displaying the numbers nicely. But that’s just my preference.
I know other do pad the numbers. And that is alright when both the audio files and the player handle that. One should just be aware, that track numbers might not always be displayed or even stored (MP4) that way.
Maybe also interesting in this regard is our FAQ about storing Vinyl style track numbers (A1, A2, B1 etc.): https://picard-docs.musicbrainz.org/en/latest/faq/faq_file_formats.html#why-does-picard-not-use-vinyl-style-track-numbers-e-g-a1-a2-by-default
Edit: The above is all about the tags. I prefer padding disc and track numbers in filenames.
1 Like