Actions and batch-operations

Mp3tag provides a variety of actions, which can be applied to filenames and tags. The actions are grouped together into named sets (action groups), which can be applied independently via Alt + 6. If you do not want to create a reusable action group for applying one single action, the Actions (Quick) toolbar button or keyboard shortcut Shift + Alt + 6 can be used.

How to create a new action?

How to ...

6 Likes

How to create a new action?

First, create a new action group via Actions > Actions Actions or Alt + 6.

Then, click on the button New New and give your action group an expressive name, e.g., "All tag fields Upper Case". This action group can be applied to the selected files after you have added one or more actions to it.

Now, you can create a new action in your action group via the button New New and choose the desired action type from the list.

At the moment the following action types are available

You can combine different actions (e.g., Case conversion and Replace) in one action group and activate or deactivate them via the checkmarks in the Actions > Actions Actions dialog.

1 Like

How to change upper/lower case of tag fields or filenames?

Create a new action in an existing action group and choose Case conversion as action type.

  • Field determines which parts of the tags/filename should be changed.
  • Case conversion determines how the upper/lower case of the field will be changed.

If you want for example mark chars after a left parenthesis or a hyphen as the begin of a word, enter the respective char under Words begin from/after any of.

2 Likes

How to replace the string "xyz" in tag-fields or filenames?

Create a new action in an existing action group and choose Replace as action type.

  • Field specifies the parts of the tags/filename the replace rule should be applied to.
  • Original is the string that is going to be changed in Field.
  • Replace with is the string that replaces the string in Original. If you leave it empty, the string will be deleted.
2 Likes

How to append the string " xyz" to the content of a tag field?

Create a new action 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: %comment% xyz

You can use this also to add "xyz " in front of the tag value, combine fields or to copy one value to another field.

3 Likes

How to remove text strings?

In order to remove text strings, create a new action in an existing action group and choose Replace as action type.

  • Field: Here you can enter which field(s) you want to change.
    You can choose

    • _ALL, which affects tags AND filenames,
    • _TAG which affects all tag fields,
    • _FILENAME which only affects the filename,
    • or simply one of the other supported tag fields.
  • Original: Here you enter the string that you want to delete.

  • Replace with: Just leave this empty, because you're going to delete the string in Original.

Example:
Assume that you want to remove Obsolete from the filename ThisShouldRemainObsolete so that ThisShouldRemain is the result. To achieve that, just enter Obsolete at Original.

3 Likes

How to add additional spaces around dash?

In order to get better readability for a filename like "Artist - Title", you can add spaces so that it reads "Artist  -  Title"

Create a new action in an existing action group, choose Replace as action type and enter (without the quotes):

  • Field: _FILENAME
  • Original: " - "
  • Replace with: "  -  "

You can activate the action group via Convert, Actions Actions and apply it to the selected files.

Unintended duplication of spaces can occur, if you're executing this action several times. "x - x" becomes "x  -  x", and "x  -  x" becomes "x   -   x" etc. You can prevent this by adding a second action that makes "   " (3 spaces) to "  " (2 spaces).

It is even more simple if your files are already properly tagged: you can use the converter Tag - Filename Tag - Filename with the format string "%artist%  -  %title%" and get the same result.

1 Like

How to remove a certain number of leading chars?

In order to remove some leading characters from the filename or a tag field, create a new action in an existing action group and choose Replace with regular expression as action type.

  • Field: choose where you want to remove the chars.
  • Regular expression: enter ^.{3} if you want to remove 3 chars.
  • Replace matches with stays empty.

You can enter the number of chars to be removed between the two curly brackets.

To remove the last 3 characters use .{3}$ (but do not use this on _FILENAME as it would remove the file extension).

2 Likes

How to remove specific leading characters?

Some titles start with "The", others with "Der" or "Die". Mass-deleting the first 3 characters doesn't have the desired result, because all other tags/filenames will be shortened too.

To remove specific leading chars, create a new action in an existing action group and choose Replace with regular expression as action type.

  • Field: choose where you want to remove the chars.
  • Regular expression*: enter ^The\s+
  • Replace matches with stays empty.

If you execute this action on your selected files, all The's and following spaces will be deleted. Of course, it works the same way with any other word.

3 Likes

How to remove/trim leading and trailing spaces

Video tutorial for these actions

Leading spaces:

Action type: Replace with regular expressions
Field: _TAG
Regular expression: ^\s+
Replace matches with:

^ matches the beginning of the string. Then \s+ searches for all whitespaces till a different char occurs.
The whitespaces found will be replaced by nothing and, thus, deleted.

Trailing spaces:

Action type: Replace with regular expressions
Field: _TAG
Regular expression: \s+$
Replace matches with:

This regular expression matches one and more (marked by +) spaces (marked by the \s specifier) at the end (marked by $) of a string.

Trailing spaces from filenames:

An action that doesn't remove the file extension:

Action type: Format value
Field: _FILENAME
Formatstring: $trim(%_filename%)

Cut two or more consecutive spaces to one:

Action type: Replace with regular expressions
Field: _ALL
Regular expression: \s{2,}
Replace matches with: " " (without the quotes)

6 Likes

How to remove/trim leading track numbers?

Action type: Replace with regular expressions
Regular expression: ^\s*\d+\s*-\s*
Replace matches with:

This regular expression removes the track number from 01 - Anything.. so that only Anything... remains.
^ matches the beginning of the string. Then any numbers of whitespaces \s* followed by numbers from 0-9.
The \s*-\s* part removes the hyphen and any whitespace characters around it.

4 Likes

How to separate or split strings that are written in one word?

You have titles that have no spaces between words (written in one big word) and all words start with a capital letter, e.g., ThisIsTheTitle (also referred to as CamelCase). How can Mp3tag separate the individual words and insert a space before every capital letter?

Create a new action group, e.g., TagsLikeThese for the field you wish to edit (the example uses the TITLE field):

Action type: Replace with regular expression
Field: TITLE
Regular expression: (\l)(\u)
Replace matches with: $1 $2
[x] case-sensitive comparison

or
Regular expression: (\w|,)(?=\u)
Replace matches with: $1 $2
[x] case-sensitive comparison

How to apply upper case after an O' (like O'Hugo)?

There are irish/scottish names like O'Donnel, O'Leary etc, that all should be upper case. But you cannot use upper case in general after an ' because other words would be spelled wrongly then (That'S, Ain'T etc.).

Action type: Replace with regular expression
Regular expression: O'(.{1})
Replace matches with: O'$upper($1)
[x] case-sensitive comparison

How to swap the contents of 2 tag fields?

Example how to swap TITLE and ARTIST:

Create a new action in an existing action group or make a new action group.

Action type: Guess values
Source format: %title%~%artist%
Guessing pattern: %artist%~%title%

Note: The ~ sign is just used to separate the two fields, you could take any other sign that does not appear in your fields, e.g. ¢ or an extended unicode character like ∞ or ∑.

6 Likes

How to copy one field value to another field?

Example how to copy the content of the ARTIST field to the ALBUMARTIST field:

Create a new action in an existing action group or make a new action group.

Action type: Format value
Field: ALBUMARTIST
Format string: %artist%

Note: If you want to copy all possible values of a field (in case you have multiple artist fields), the internal scripting function $meta_sep can be used in the format string, e.g., $meta_sep(artist,\\\\)

2 Likes

Organizing Actions

Keyboard Shortcuts

While it's not directly possible to assign arbitrary keys to action groups, you can use the keyboard shortcut to trigger the action group menu Alt+A in combination with another character from the action group name. Simply decide on the character and prefix it with &. You can then use Alt+A and the character to trigger the action group.

An example action group &Uppercase can be triggered by Alt+A plus U.

Submenus in the Action Group menu

If you use the # in your action group name, Mp3tag uses anything before the # as name for a submenu and anything after as a menu item in that menu. By that, you can organize action groups that belong together.

An example action group Default values#Set COMMENT would create a submenu Default values and would list the action group Set COMMENT within this menu.

Pro tip: you can combine both tips, e.g., &Default values#Set &COMMENT to trigger the action group by pressing Alt+A plus D plus C.

1 Like