Determining Tag - Filename when multiple ID3v2 artists tags present

I am trying to use the "Tag - Filename" option to set the filenames of mp3 ID3v2 files, using this format string:

$if($meta(artist,1),Various Artists,%artist%)_%album%_$num(%track%,2)_%title%

but it is not recognizing when multiple artists exist. This format string is attempting to recognize when there are multiple artists in the tag and switch the artist portion of the name to "Various Artists", to prevent creating overly long filenames when there are lots of multiple Artists in a song. Example:

The song "7" by Prince, is tagged with multiple artists "Prince" and "The New Generation". In Mp3tag the Artist displays the multiple Artists "Prince / The New Generation". But the formatting string "$if($meta(artist,1),Various Artists,%artist%" is not finding a second artist in the offset "1" position.
Using this same formatting string in Foobar2000's File Rename recognizes it, so I'm wondering what the difference is in Mp3tag's recognition of multiples in the Artist tag and how to fix it.

And I'll say ahead of time that I do not want to tag files like this as "Various Artists" in the Album Artist because this is essentially the same Artist (Prince, aka The New Revolution), these are just two artist names for the same primary artist, Prince... I am just applying this naming scheme to the filename to keep its length under control but still adhere to a decipherable standard.

Any help is appreciated.

It's simply missing the closing parentheses. Try

$if($meta(artist,1),Various Artists,%artist%)

it does have the closing paren in the full example at the top of the post, I must have just truncated off the closing paren when pasting into the later quote, sorry:

$if($meta(artist,1),Various Artists,%artist%)_%album%_$num(%track%,2)_%title%

Just guessing of course but I wonder if the designating "/" between the multiple artists is not seen by the formatting string because it is being removed before handing it over to the formatting string because "/" is an invalid character for a filename? I wonder that because in the Preview for that format string it displays

Prince  The New Power Generation_The HitsThe B-Sides_18_7.mp3

with 2 spaces between "Prince" and "The New Power Generation" as if the "/" was already squeezed out between the spaces.... just a thought.

Interesting. You probably have only one single artist field containing multiple artists separated by the / character.

In Mp3tag, real multiple values are denoted by \\ in the Tag Panel and are listed as separate entries at Alt + T. $meta(artist,1) returns the 2nd of those multiple values and does not return anything if you only have one value for the artist field (even if it contains multiple names).

Oh yes I remember now that Mp3tag does not try to recognize any internal splitting of multiple artists within the same TPE1 frame, although this is a convention for multiple artists in ID3v2 because the TPE1 frame is not supposed to be repeated. So the "/" between them is simply interpreted as data within the artist? If so why is it being stripped off before handing it to the formatting string? I tried instead to recognize the multiples by looking for a "/" or two consecutive spaces in the artist, but am having trouble with that one... any suggestions?

whoops my bad,


doesn't write two TPE1 frames, it uses a separator within the frame.

Ok I think I found a workaround:

$ifgreater($strstr(%artist%, / ),0,Various Artists,%artist%)

This looks for a return of greater than 0 for the string search of multiple artist separator "/" with a space before and after it and if it returns true (greater than 0) it puts "Various Artists" in the Artist node of the filename, else %artist%.

And here it is incorporated into the full format string that also replaces invalid filename characters that are valid in tags:

$replace($ifgreater($strstr(%artist%, / ),0,Various Artists,%artist%)_%album%_$num(%track%,2)_%title%,/,-,:,-,\,-,|,-,*,x,?,~,<,~,>,~)

This appears to work, thanks.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.