Parentheses to brackets if content contains keywords

I’m trying to incorporate an Mp3tag action directly into Picard using tagger script. Unfortunately it’s not recognized as is and I’ve tried to modify it without any luck.

The goal is to change titles that looks like this:

Bette Midler - Just My Imagination (Running Away with Me) (album version)

into this:

Bette Midler - Just My Imagination (Running Away with Me) [album version]

In other words, I need to replace parentheses with brackets, but only if certain keywords like remix, album version, acoustic, etc. is present within the parentheses.

This is what my Mp3tag action looks like:


I ran across a thread on stackoverflow that deals with this exact problem, but none of the solutions provided in that thread does anything whatsoever to my tags. Help would be extremely appreciated!

Are you entering this as a user script or in the naming script, because it shows an error here. $regexp() is not a valid script function. Perhaps you should be using $rreplace()? Also, I don’t see any of your brackets escaped (as explained in the accepted answer for the stackoverflow article you linked).

I don’t have any time right now, but will try to get back to this later (unless someone beats me to it).

I’m entering it as a user script. I figured that made the most sense seeing as I want the above formatting in both the title tag and the filename.

I was getting the same error and I’ve already tried using $rreplace and I was under the impression that would work as the formula looked correct to me.

The brackets are not escaped, which is weird. I thought that was a regex thing but yet that exact formula works in Mp3tag. If I escape the brackets I get an error that says “Unexpected character “b””. If I remove “\b” the error message says “Wrong number of arguments for rreplace”. That leads me to believe that $rreplace will not work with the way this particular formula is outlined.

Also, I tried using the formulas from stackoverflow but they did nothing to my files. As the thread’s a couple of years old, I just figured they weren’t compatible with my version of Picard.

Actually the selected answer from the stackoverflow article was almost exactly what you needed. I took that, properly escaped the strings for Picard, added a $set() wrapper and changed the replacement from $1 to \1, and it looks to be working perfectly. My result is:


Give that a try and see if it does what you want.


I added a couple of keywords that I wanted and the formula you provided works perfectly. It never occurred to me to use $set but it seem to have done the trick. Going to try to dissect it a bit more and see if I can learn anything new from it. Thanks again for the assistance!