How to import a custom action group from a file

I would like to use the scripting functions https://docs.mp3tag.de/scripting/ to create a text file that I could import to the Mp3Tag Actions menu using the Import...function under Action Groups.

Is it as simple as creating a text file containing the line(s) of scripting functions?

If I want to perform an action based on the result of a consecutive series of "if" functions, it is as simple as just creating a series of "if" functions in the file, assuming the the "if" condition will be matched by one and only one time for each track? Or is there a way to use an "else" clause?

What I would like to do is write an action that looks at the current contents of the "comments" tag, and depending on that value, appends a value to the existing "genre" tag .

In many cases an action of the type "Format value" for GENRE with a format string that uses $replace() can be quick way.

Please supply a real example.

It is not advisable to create actions outside the MP3tag actions editor.

Your Actions are saved as *.mta files in the subfolder
%appdata%\Mp3tag\data\actions

If you write such a file externally and copy & paste it in this folder, it should be recognized by Mp3tag (assuming they are error free...)

I'm not sure if I understand the advantage of such a process.

Just a hint for very complicated structures: I sometimes use the Export Function of mp3tag to a csv-File (there are some nice examples with csv-Syntax and coloumns in the forum). Then you can use (if you have) Excel for your If-clauses or complicated syntax (vlookup, index). You can re-import the tags via "Convert" and "Textfile to tag". It's probably not worth for 10 files... You can also use Excel to perform the correct Syntax for the "mp3text.txt" for the re-import to mp3tag (via #%_filename_ext%). It's possible to re-import several files together in one "mp3text.txt" (see examples in the forum).

Existing Tags:

**Filename   ...         Genre       ...           Comment**   
Track1                   Rock                      Mom
Track2                   Rock                      Dad
Track3                   Rock                      Mom & Dad

I would like to write an action such that (in C-like pseudocode):

switch (comment)
{
   "Mom":
      genre = %GENRE% + ";" + "Mom";
      break;
   "Dad":
      genre = %GENRE% + ";" + "Dad";
      break;
   "Mom & Dad":
      genre = %GENRE% + ";" + "Mom" + ";" + "Dad";
      break;
}

Resulting Tags:

**Filename   ...         Genre       ...           Comment**   
Track1                   Rock;Mom                  Mom
Track2                   Rock;Dad                  Dad
Track3                   Rock;Mom;Dad              Mom & Dad

It just seems like it would be easier to create a script in a text file to do that, vs wrestling with the "Action Group" dialog box.

The reason that I want to do this is that I'm moving from a music server that let me create smart playlists from the "Comment" tag to Plex, which only references certain tags for use within smart playlists..."Comment" not being one of them. So I'm basically trying to bulk-move the existing work that was done over to using the "Genre" tag, while preserving the existing Genre information (Plex allows a semicolon delimiter for specifying multiple values for Genre tag).

So, this is what I tried to cobble together using the Actions dialog box:

$if($stricmp(%COMMENT%,Mom),%GENRE%;Mom,$if($stricmp(%COMMENT%,Dad),%GENRE%;Dad,$if($stricmp(%COMMENT%,Mom & Dad),%GENRE%;Mom;Dad),NONE))

(For debugging, I made the final ELSE "NONE" so that it would change the value of GENRE to some known error value. In the working action, I would want to leave the GENRE unchanged & therefore make the final ELSE just %GENRE%).

If I run this action against a track with "Mom" as the comment, I get the expected result for GENRE, "Rock;Mom". Running it against records with any of the other value in the comment results in GENRE being blank, which I'm assuming is a side-effect of the action silently failing.

So, I guess either I'm not mastering how to implement multiple "if, then...else" type actions, or there's a bug in the functionality. Probably the first thing. :grinning:

It looks to me as though you simply add the contents of COMMENT to GENRE
For that procedure, there is even a post in the FAQs:

In your case, I would create an action group with 3 actions:

  1. Format tag field for GENRE
    Format string: %genre%\\%comment%
  2. Merge duplicat tag fields for GENRE
    Separator: ;
  3. Replace for GENRE
    Search: &
    Replace with: ;

That should lead to the same result as your list. No ELSE required.