Picard doesn't add track numbers to filenames in some albums, removes existing numbering

This issue seems to be limited to albums which aren’t identified with the program (“scan”, “lookup”). Some of the albums I’m having problems with are my private home recordings and there is no purpose in uploading them.

I’ve only added a folder, then clustered the files and started editing tags. When saving, Picard removes track numbers from the filenames — I’ve reproduced this multiple times. The “track number” tag is saved correctly and created if not in existence.
Tracks on albums with a database entry are renamed correctly.

This is my file-naming syntax (no changes aside from a single dot):

$if2(%albumartist%,%artist%)/$if($ne(%albumartist%,),%album%/,)$if($gt(%totaldiscs%,1),%discnumber%-,)$if($ne(%albumartist%,),$num(%tracknumber%,2). ,)$if(%_multiartist%,%artist% - ,)%title%

Picard version 2.0.3, Windows 10

My first guess would be that you don’t have the track number in the file tags, and therefor when saving there is no track number in the filename.

I was about to write a lengthy post about what you can do to get the tag number from the file names, but then I found out during testing that Picard will already guess the tag number from the filename if it is not set in the tags. Awesome, I didn’t know about this :smiley:

Now the question is why this doesn’t work for you or what else is wrong. Can you give an example of an existing filename that does not work?

Also after adding that file to Picard look at the metadata at the bottom. Is the track number set?

2 Likes

I use this naming scheme for my music files:

01. track title
02. track title
03. track title
04. track title 
05. track title
...

Picard has added the “track number” tag to every song from the filenames. I’m now adding this information to my post, sorry for not mentioning in the first place.

Ok, that’s working fine so far. But I now see the issue. This part of your script is at fault:

$if($ne(%albumartist%,),$num(%tracknumber%,2). ,)

This is adding the track number only if there is an albumartist set, and I guess that is not set for your local files. I am not really sure what the logic behind this is. But just replace that part with just

$num(%tracknumber%,2).

and it should work.

2 Likes

I don’t understand scripting correctly, thank you. However, one of my albums certainly did have the “artist” tag set, but modifying script solved the issue — I would like to know the reason.

$if2(%albumartist%,%artist%)/$if($ne(%albumartist%,),%album%/,)$if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2). $if(%_multiartist%,%artist% - ,)%title%

artist is not the same as albumartist. An album can be attributed to an artist, and that will be set as albumartist. But not every track on that album needs to be attributed to that artist, there could e.g. be guest performances by other artists. Hence the artist tag for each track can be different .

For your local files you likely often have only artist set.

3 Likes

Thank you, this finally resolved the issue. I will add both artist and albumartist to my own recordings from now on.