# How to import a custom action group from a file

**URL:** https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229
**Category:** Support
**Created:** [January 21, 2025, 5:40pm UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229 "2025-01-21T17:40:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![atebit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@atebit](https://community.mp3tag.de/u/atebit)
#### Post date: [January 21, 2025, 5:40pm UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/1 "2025-01-21T17:40:22Z")

</div>

I would like to use the scripting functions [https://docs.mp3tag.de/scripting/](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 .

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [January 21, 2025, 5:44pm UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/2 "2025-01-21T17:44:49Z")

</div>

> [@atebit](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 21, 2025, 5:46pm UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/3 "2025-01-21T17:46:15Z")

</div>

> [@atebit](#):
>
> Is it as simple as creating a text file containing the line(s) of scripting functions?

Your Actions are saved as \*.mt **a** 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.

---

<div class="post-metadata">

### Author: ![Patrick](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/p/b2d939/32.png) [@Patrick](https://community.mp3tag.de/u/Patrick)
#### Post date: [January 21, 2025, 8:24pm UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/4 "2025-01-21T20:24:06Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![atebit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@atebit](https://community.mp3tag.de/u/atebit)
#### Post date: [January 21, 2025, 10:41pm UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/5 "2025-01-21T22:41:23Z")

</div>

Existing Tags:

```auto
**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):

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

```

Resulting Tags:

```auto
**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).

---

<div class="post-metadata">

### Author: ![atebit](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@atebit](https://community.mp3tag.de/u/atebit)
#### Post date: [January 22, 2025, 2:52am UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/6 "2025-01-22T02:52:36Z")

</div>

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. 😀

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [January 22, 2025, 7:18am UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/7 "2025-01-22T07:18:52Z")

</div>

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:

> [@Actions and batch-operations](https://community.mp3tag.de/t/actions-and-batch-operations/967/5):
>
> How to append the string " xyz" to the content of a tag field? Create a [new action](https://community.mp3tag.de/t/actions/967/2) in an existing action group and choose Format value as action type. Field specifies the tag field the formatting rule should be applied to. Format string must have the field placeholder for the field selected above and the string which should be appended. Example: If you want to append the string " xyz" to the current value of the comment field: Action type: Format value Field: COMMENT Format string: %com…

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.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [February 21, 2025, 7:18am UTC](https://community.mp3tag.de/t/how-to-import-a-custom-action-group-from-a-file/67229/8 "2025-02-21T07:18:55Z")

</div>

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