If/then for artist/genre?

Hi all,

I know this might be a bit of a long-shot (or not?) but I was wondering if there was a way (as part of an Action Group, maybe?) where Mp3tag could format the Genre value based on the Artist's value where it references a list of conditions that I would update manually.

For example, if Artist = Beethoven, then Genre = Classical
if Artist = Eminem, then Genre = Rap, etc.

As time goes on, I would add new artists/genres to the script.

Apologies if I'm not using accurate terminology. I know this sounds tedious but in my specific use-case it is preferable. Thanks.

Yes, you can use Actions with the scripting functions.

There you could use "Format Value" for the field GENRE and something like
$if($eql(%ARTIST%,Beethoven),Classical,Not Classical)


But you have to repeat this action for every artist you want to set the genre.
And the name of the artist has to match exactly to apply the new content for GENRE,
so Ludwig van Beethoven as artist name would not match the example above.

As you can see in the example from @ohrenkino you could set the ELSE case (if the artist name does NOT match your text) to %GENRE% instead the fixed "Not Classical". This would leave the current content of GENRE untouched if the artist name can not be matched.

1 Like

Even though I think that the direct assignment of a genre to a particular artist is much more flexible - esp. as there are some artists that make music for different genres, you can create an action group with actions of the type "Format value" for GENRE
Format string: $if($eql(%artist%,Eminem),Rap,%genre%)
Format string: $replace(%artist%,Eminem,Rap,Beethoven,Classical)
Fell free to complete the pairs.

1 Like

Thank you so much for the replies, I did a few tests and this is exactly what I was looking for.

1 Like

Would I be able to string together multiple if/replaces into one string and leave the field unchanged/blank if no matches found?

I tried this but it doesn't seem to work:


(the $if() function is applied with an invalid syntax, so that would not work anyway)

No, either you go the $if-way or the $replace-way.
The result of $replace() for no match found is that %artist% gets inserted in GENRE. So in the end you could filter for files where GENRE equals ARTIST.

Actually, I would assume that you apply such an action only to artists where you know which genre they should serve, so that the "no match" condition never occurs.

Or you create an action group that first replaces and as a last action checks whether ARTIST and GENRE are the same and then deletes GENRE.

Thanks for all the assistance

Theoretically this is possible, yes.
You would have to double the $replace and compare the outcome like this


The logic behind this complicated Format string is:
a) Check if the current content in %ARTIST% is NOT the same as the outcome of the first $replace(...).

As @ohrenkino wrote, if there is no match in the first $replace(...), the content of ARTIST will be filled into GENRE.

b) If the condition in a) is TRUE (= the ARTIST is NOT the same as the content of GENRE = the GENRE would be replaced) then execute the second $replace(...). This second $replace will replace the genre with the text you set here.

c) If the condition in a) is FALSE, then leave the GENRE untouched

As you can see, this becomes practically unusable, because you always have to adjust the Artist & Genre pairs in both $replace(...)

If you imagine that you want to be sure to find "ACDC", "AC/DC", "AC-DC", "AC🗲DC" and all the other thinkable variations to replace the genre with "Hard Rock" (or is it "Bluesrock" or "Rock 'n' Roll"?), I can not seriously suggest to go this way.

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