Problem with Actions and Regular Expressions

I wanted a solution to a simple problem. Many of my tracks have blank Album Artist tag, and I wanted to replace those tags with the Artist tag whenever it is blank (equal to "null string," "empty tag," etc.) I found this action quite difficult, much more difficult than it needs to be.

First of all, what the program calls "Album Artist" is really the "Band" ID3 tag. That took me a little while to figure out in and of itself. The "Album Artist" tag, if it exists, is irrelevant. Because the tag "Album Artist" has a space in it, can't even be referred to anyways!

After a ton of searching, head-scratching, researching, and trial-and-error, I finally came up with something that works. Unfortunately, MP3tag does not seem to have a way of directly representing the null string, but I came up with this expression that works:

Action type: Format Value
Field: BAND
Format string: $if($geql($len(%band%),1),%band%,%artist%)

The literal way to read this code is: If the length of "Band" tag is greater than or equal to one character, then the "Band" tag is equal to the "Band" tag, otherwise the "Band" tag is equal to the "Artist" tag.

The effect of this is: It will check all selected files and, if the "Band" tag (i.e. Album Artist) is blank, it will replace it with the "Artist" tag; otherwise it will leave it alone. If there is a more elegant code to solve this problem, please feel free to correct it.

  1. Thank you for sharing your Mp3tag knowledge. That is the stuff from what Mp3tag is living.

  2. Do not post into a pinned thread when your content does not fit to the theme of the thread, e. g. this thread "Replying to Regular Expressions" works on the area of regular expressions.
    Because you have written about a solution using standard scripting functions, then use another area of the Mp3tag forum to publish this into the right context to reach your target people.

  3. Regarding the tag field BAND and other tag field names in Mp3tag and their usage in other programs look there:

  4. The scripting functions help says: $if2(x,y) if x is true, x is returned, otherwise y.
    You can simplify your expression to: $if2(%BAND%,%ARTIST%).

  5. Look there to find some interesting messages about BAND and ALBUM ARTIST and so on:

  6. Regarding your statement "Because the tag "Album Artist" has a space in it, can't even be referred to anyways!" I think this is not correct, but I do not know for sure.

  7. You should proove your opinion of ARTIST and ALBUM ARTIST and BAND.
    My opinion is .... an ARTIST is not the BAND (not in all cases).

Anyway, welcome to Mp3tag, and have good luck with your further investigations!


In reply to post #25 on Jul 29 2009, 04:55:

MP3tag is a customizable program whose advanced features are difficult to figure out whose help file which is also rather abstruse. These forums are also hard to figure out. I still don't know what the term "regular expression" means in the context of MP3tag. I still think it just means a scripting/coding expression used in MP3tag. I didn't even know about the existence of the "$If2()" command. These difficulties are coming from someone who has taken a few C++ coding classes in college and is highly computer literate, so I certainly do have some familiarity with computer coding.

Not only that, but us English-speaking folks have to wade through forums which may be in either English or in German. And vice-versa, of course. Sprechen Sie Deutsch? And yeah, I took German in high school as well, but I'll be damned if I can still read it today, especially casually.

What I'm trying to say is, a post in the wrong category is completely unsurprising given the complexity of the program's scripting functions and the poor user-friendliness of the help program (i.e. this site). I posted in the "Regular Expressions" thread on this forum because I used the "Replace with Regular Expression" action. It made sense to me to post here. But thank you for replying to my post and adding to it - I just think that posting something which is nearly on topic should not deserve criticism.

No, "Band" and "Artist" are certainly not the same, however, if the "Band" tag is blank or not available, the next-best option is to set it to whatever the "Artist" tag is. Most of the time they are the same for most albums, so this is a good enough solution for me, at least when dealing with lots and lots of songs and albums. Whenever "Artist" and "Band" are not the same, they can be corrected manually.

Split from Regular exp​ressions since these posts did not contribute to the topic's intent to collect some useful regular expressions.

Please read Regular Expression (or at least the overview part of it) if you want to learn something new. Regular Expressions is a language that finds patterns in strings and can be used for searching or -- as in Mp3tag -- for replacing matches by a given string.

There is a clear distinction between the German and the English written parts of the forum. If you don't like to see the German forum please use this link when navigating to the forums. Please also select International part when using the search function.

Detlev was not criticising you but provided a helpful welcome post pointing you in some interesting directions.

Kind regards,