Double THEN statement in IF

I have made the following action for each artist i own to match them with a specific genre if this is not already set on Soundtrack:

Source Format: %GENRE%
Format string: $if($and($neql(%genre%,Soundtrack),$eql(%artist%,Artist1)),Genre1,%genre%)

The last thing i cant figure out is to add another condition to the else function so afterwards i can filter the ones that are not met by the if statement. So besides changing the genre when the artist is not present i want to replace a field e.g. %land% with the text (new). I already tried adding the text (new) behind the genre but then it adds (new) to the genre in any case the genre is not changed and keeps adding to it when the keep calling the action:

$if($and($neql(%genre%,Soundtrack),$eql(%artist%,Artist1)),Genre1,%genre% (new))

Anyone who has a solution for this?

Thanks in advance

Well, I do not understand your description of the wanted algorithm yet, but I have tried so far, just for illustration ...

$if($and($neql(%GENRE%,'Soundtrack'),$eql(%ARTIST%,'Artist1')),'Genre1',%GENRE%) $if(condition-------------------------------------------------,then----,else---) ... gives 2 cases. $if(condition1,then,$if(condition2,then,else)) ... gives 3 cases. $if(condition1,then,$if(condition2,then,$if(condition3,then,else)) ... gives 4 cases. $if(condition1,then,$if(condition2,$if(condition3,then,else),$if(condition4,then,else)) ... gives 5 cases. $if(condition1,$if(condition2,then,else),$if(condition3,$if(condition4,then,else),$if(condition5,then,else)) ... gives 6 cases. ... and so on ... Sometimes a bunch of unique cases can be solved by a series of $if clauses, collected in one Action Group ... $if(condition1,then,else) $if(condition2,then,else) $if(condition3,then,else) $if(condition4,then,else) $if(condition5,then,else)

You may stack respectively nest as many function calls as needed, ... I do not know the limit of Mp3tag.

Maybe you can describe your goal with other words or by a fitting example?

Maybe you want something like this ...

Action #1 ..: Format Value Field ......: LAND Formatstring: $if($and($neql(%GENRE%,'Soundtrack'),$eql(%ARTIST%,'Artist1')),'(new)',%LAND%) Action #2 ..: Format Value Field ......: GENRE Formatstring: $if($and($neql(%GENRE%,'Soundtrack'),$eql(%ARTIST%,'Artist1')),'Genre1',%GENRE%)


Thanks for your reply. I will clarify my wish:

When an artist already exists in my library i want to assign the genre for it i choose in the past, therefore i exported all my artists with their chosen genres and filled in the following action by the always handy Word Mailing :slight_smile: :

$if($and($neql(%GENRE%,'Soundtrack'),$eql(%ARTIST%,'Jon Hopkins')),'Idm Ambient',%GENRE%)

So this works but what to do with new artists? I thought of adding a characteristic to the genre tag or another field so afterwards i can filter them and only review the new artists. Besides that i will do a yearly export to keep my list of existing artists with their genre complete.

The examples of the two situations im trying to cover in one action (so as an extension of the existing action if possible) are these:

Artist: Jon Hopkins
Genre: Techno

$if($and($neql(%GENRE%,'Soundtrack'),$eql(%ARTIST%,'Jon Hopkins')),'Idm Ambient',%GENRE%)

Artist: Jon Hopkins
Genre: Idm Ambient

For a new artist i just downloaded and not my action group with all known artists with their genre::

Artist: Marisa Monte
Genre: Brasileira

action above with extension

Artist: Marisa Monte
Genre: Brasileira (new)


Artist: Marisa Monte
Genre: Brasileira
Land: (new)

I tried something like this but probable the and function is not possible without an if?:

$if($and($neql(%GENRE%,'Soundtrack'),$eql(%ARTIST%,'Jon Hopkins')),'Idm Ambient',%GENRE%)$and($replace,%GENRE%,%GENRE%),$replace(%LAND%,'(new)')))

Hope this makes it more clear

  1. The functions "$and, $or, $eql, $not" etc. are boolean functions (see manual), ...
    that means, their result is only a invisible boolean value of "true" resp. "false".
    These functions are not able for connecting strings or other string manipulations.

  2. I understand your problem this way, that you need a sort of lookup table, where you can search for a dedicated input value and find the related output value.

You can create such a lookup table as a simple text file, having two columns, the search column and the find column, e. g. ...
Jon Hopkins|Techno
Marisa Monte|Brasileira

Using Mp3tag Actions you can load this text file into a helper tag-field.
Then look for the search value in the helper tag-field, e. g. "Jon Hopkins", and extract the related find value "Techno".

See there ...
match some words from comment and put them in genre

In the past I did several attempts to do so within Mp3tag, you have to find them somewhere in the Forum.

The first step would be ... set a default value for the genre, like "---unknown---" or such, ...
then try to find the proper Artist, ...
then get the Artist related Genre value, ... and use it, ...
otherwise leave the genre tag-field as is or remove it.

See above post #2, last proposal.
If you want to change two different tag-fields, using the same condition, ...
then you have to apply two actions, one for each tag-field, using the same condition.


I would like to add that apart from the technical implications there is also a semantical.
I simply doubt that you will go very far with a 1-to-1-relation of artist and genre.
If you have a farily decent artist he will not simply cling to one single genre but be much more variable.
So in the end you have to judge track by track what kind of genre can be assigned.

Yes, you are right.
An artist can have multiple genres in his entire work.


Thank you for your help and time! This saves me a lot of time trying the make it work while it is not possible. I will look into your suggestion for the helper tag-field. That is functionality i did not look into yet. For me this will probably be the fastest and easiest way, so thanks again.

As for the semantics goes, it is a fact there are artists that are between genres or can be fitted in multiple genre per track or per album but for me the most important use of genre is a solid (limited) overview of genre and artists per genre instead of a never ending list of artists with a handful of tracks in each genre. So pointing a specific genre to one artist works in my situation the best. The differences in genre per track or album don't really change that much for most artists and usually can be fitted in a frame (although the artists probably don't like to hear that :slight_smile: ).

And even one song can be assigned to different genres.