Is splitting fields this way even possible?

I know there's a Picard plugin that does exactly this called "Standardise Performers". Unfortunately, 2/3 of my library has already been tagged without this plugin enabled. I'm now trying to clean up this mess, hoping it's possible using MP3tag actions and without having to run thousands of albums through Picard a second time.

Here's an example of my current tags presented as "field = value":

PERFORMER = John Cale (Celesta, Organ and Piano)
PERFORMER = Dave Pegg (Bass)
PERFORMER = Mike Kowalski (Drums)

What I'm trying to achieve is to make sure there's only 1 instrument encased in parentheses per tag, which would result in this:

PERFORMER = John Cale (Celesta)
PERFORMER = John Cale (Organ)
PERFORMER = John Cale (Piano)
PERFORMER = Dave Pegg (Bass)
PERFORMER = Mike Kowalski (Drums)

The variable here, amongst thousands of files, are the number of instruments encased in parentheses. Some will have only one, some will have two separated by " and ", some will have three or more separated by commas and " and ", like so:

John Cale (Celesta and Piano)
John Cale (Celesta, Organ, Guitar, Bass, and Piano)

I've been racking my brain trying to come up with a solution to make this happen and I'm seriously starting to doubt if it's even possible. Any input from those of you who know this application inside and out would be very much appreciated. Thanks in advance!

I can't think of a generic solution at the moment, but you can use several actions of type Replace with Regular Expression and start from replacing the longest sequence to the shortest.

An example which assumes that there are at most five instruments, e.g., as in
PERFORMER = John Cale (Celesta, Organ, Guitar, Bass, and Piano)

Regular expression: (.+) \((.+), (.+), (.+), (.+), and (.+)\)
Replace matches with: $1 ($2)\\\\$1 ($3)\\\\$1 ($4)\\\\$1 ($5)\\\\$1 ($6)

The next action in the action group would be the expression for four instruments:

Regular expression: (.+) \((.+), (.+), (.+), and (.+)\)
Replace matches with: $1 ($2)\\\\$1 ($3)\\\\$1 ($4)\\\\$1 ($5)

And so on until:

Regular expression: (.+) \((.+) and (.+)\)
Replace matches with: $1 ($2)\\\\$1 ($3)

The trick is to leverage that only exact matches are replaced.

I very much appreciate you taking a look at it, thank you. Your approach was the best I could come up with as well but I didn't know how to formulate the regex, and also, a part of me was hoping there would be a generic solution I just didn't see, but I do understand if there isn't/can't be. A large screw up usually takes some amount of work to clean up.

Going through my files I realized that my example of 5 instruments were a bit too conservative as I found files that has 14 of them - that's a hell of a lot of actions...

This solution will definitely be my fallback as it beats having to run everything through Picard again, but I would like to keep this thread open in case something else pops up.

Just a note to anyone who stumbles across this thread in the future looking for a solution and, like me, are regex newbies who just copy and paste things they don't really understand: I made a mistake in my example which, of course, is also present in the solution. There shouldn't be a comma before " and " in the examples with more than 2 instruments. Just remove that and the regex works perfectly.

Again, thank you Florian for taking this from "nearly impossible" to "possible, albeit tedious".

Edit: I just went ahead and did it. Probably took less than 30 min so I was greatly overestimating the amount of work it would take. Thanks a lot for the assistance! :smiley:

1 Like

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