Formatting Problem with Genre Tag

I am trying to do something extremely simple. Take the GENRE tag and put all of its contents insider of parenthesis.

So-

%GENRE% -> (%GENRE%)

However, I cannot get this to work. If I use 'Convert Tag-Tag', the preview will display the results properly but if executed it will just replace the tag with an empty field. This is also true if I try to use the equivalent form of Regular Expression to do the same.

I noted that the , is used to escape ( in the MP3tag documentation. Indeed, I have been able to get the parenthesis to appear properly using:

Action -> Format Value: GENRE -> ,(%GENRE%)

but that leaves me with a comma out front. But I am unable to remove that comma without blanking the entire tag.

What am I misunderstanding here?

You are right.

And it doesn't even work if you press ALT + T and enter a genre text in parenthesis completely manual. For example if you enter (Pop), you get a deleted genre field. You first see the expected entry in the metadata view, but as soon as you press OKthe tag will be deleted entirely.

The Genre field in ID3v2 is very special and you're experiencing one of the special rules. Here is a quote from the ID3v2.3 specification

TCON

The 'Content type', which previously was stored as a one byte numeric value only, is now a numeric string. You may use one or several of the types as ID3v1.1 did or, since the category list would be impossible to maintain with accurate and up to date categories, define your own.

References to the ID3v1 genres can be made by, as first byte, enter "(" followed by a number from the genres list (appendix A) and ended with a ")" character. This is optionally followed by a refinement, e.g. "(21)" or "(4)Eurodisco". Several references can be made in the same frame, e.g. "(51)(39)". If the refinement should begin with a "(" character it should be replaced with "((", e.g. "((I can figure out any genre)" or "(55)((I think...)". The following new content types is defined in ID3v2 and is implemented in the same way as the numerig content types, e.g. "(RX)".

It's very messy and you're, IIRC, the first person to stumble over this intricacy.

2 Likes

Thank you for the explanation @Florian

2 more questions:

a) How should the Tag -> Tag format string look like to put an existing genre in parenthesis?
Something like $replace(%GENRE%,(21)((%GENRE%))) doesn't work.

b) Why does a wrongly formatted string for the tag genre delete the existing one - without any hint and in contrast to the preview?

a) According the standard ((Genre) is the way to go, but this will remove the first ( on display, which will cause the observed behavior on re-write.

b) It's not deleted. Mp3tag writes (Genre) to the file but applies the special logic when reading and fails to interpret Genre as numeric value for an ID3v1 genre.

I think I'll remove much of this logic with a future update.

1 Like

Interesting!

The reason I wish to do this is I like to include Discogs genre/style tags. The way I handle it is by putting the style tags in parenthesis then sticking the genre in front, so:

Rock (Alternative, Pop)

I can do this just fine using an extension in Beatunes that writes the tag in that format by looking up the track on Discogs. It can also handle cases of multiple genres and styles, so something like:

Rock, Folk (Country Rock, Folk Rock, Celtic)

Is also possible.

However, many songs were not detected, so I use MusicBrainz Picard as a fallback for those songs. This will give me a set of tags much like the style tags from Beatunes. For the example listed, it would give me something like

Country Rock/Folk Rock/Celtic

But I’m trying to convert this to the same style I have for my Beatunes tags. Which means:

  • replace / with ,
  • stick it all in parenthesis
  • manually append the more generalized ‘genre’ tag(s) akin to Discogs

Mp3tag was the only program I could think of for achieving such a mass ‘bulk find and replace’ operation.

I will try to find a workaround.

One possible workaround would be to

  1. copy the value from MusicBrainz Picard to a temporary field via a format value action, e.g., to PICARDGENRE which has then, e.g., Country Rock/Folk Rock/Celtic

  2. manually set the GENRE to, e.g., Rock

  3. format the GENRE with a format string like
    %GENRE% ($replace(%PICARDGENRE%,/,', '))

  4. Optionally remove PICARDGENRE

1 Like