IF THEN ELSE logic in Actions

I believe this does not exist, but wanted to be sure....

Is there "iF THEN ELSE" logic available in actions?

Ex: IF %file.jpg% exists THEN ((do an action)) ELSE ((do another action))

Related: Is it possible to move an Action group to a script, so the Actions can be extended using scripting?

See the help on Scripting:
https://help.mp3tag.de/main_scripting.html#boolean
There are several $if() functions that all have an ELSE branch.
There is no function to test if an external file exists, MP3tag treats the currently loaded and selected files.

You cannot call an action group with a scripting command but there are many equivalents for actions mapped to scripting functions.
Usually, it is the other way round: you execute an action that uses scripting functions.

So to be clear: If I have SOME files for adding album art (stored as ARTIST.JPG naming scheme), I cannot do a function to say "IF artist.jpg exists, INSERT artist.jpg, ELSE insert "missing.jpg" ...?

Yes, there is no way to find out if an external file exists.
But ... if you have either the file artist.jpg in the folder or the file missing.jpg, then you could run an action to import the picture with
Format string *.jpg
This would import the first file that is found.
And as "a" sorts before "m", you would get artist.jpg where it exists.
And for all other cases you could filter for the number of embedded covers or where the cover is still missing
%_covers% MISSING

1 Like

I have a workaround that will "work", thanks. I do not store my MP3s in album folders. My workaround would be to run "add MISSING.JPG" to all MP3s... then, run the real Action, which adds ARTIST.JPG to the MP3s. Those that have no ARTIST.JPG, should "leave the MiSSING" graphic in the tag.

I wanted the same Logic for LYRIC text files. (shrug)

I don't know how this scheme is part of a workflow.
But: it is much easier to filter for missing covers than for a cover that shows "Missing".
So: if you import covers with the format string %artist%.jpg you will probably get a number of error messages that the file does not exist. You would have to acknowledge those.
But then you could filter for the files that still have no cover and see how to treat these.
Something similar would apply to the lyrics files.

Agreed, using COVER. I am unclear how you'd do that for LYRICs. Also, if there was a preexisting COVER, this would not help... unless I REMOVED cover prior to adding one.

You could filter for files that already have a cover and even if the cover type is already ARTIST.
Or the other way round: with
%_covers% MISSING
you would see the files that are in need of a picture.
THe thing with the lyrics ... the lyrics file would have to comply with the rules to import data from a text file, probably via the action "Import text file".

You also have an option with this action-type to delete preexisting covers while importing them.

1 Like