Replace part while keeping other part of the title

Hello everyone,

I've got a "title" tag that looks like this:

Title - Feat Someone - Somebody's Cover

And I want it to look like this:

Title (feat. Someone) (Somebody's Cover)

I know how to replace "- Feat" with "(feat." with an action and I tried using "*" as a placeholder (at least that's what Win 10 uses) but that didn't work. A "regular expression" action is probably required here, right? Sorry, I'm a complete RE noob. How do I add the closing bracket after the second artist and what if there's also a third one, like this:

Title - Feat Someone - Feat Someone Else

Thanks in advance!

Search string: (.*) - (.*) - (.*)
Replace string: $1 ($2) ($3)

You do not say what this one should look like.

1 Like

Thanks for your reply!
"Feat" should be replaced with a lower case "feat." and it's possible for there to be multiple "Feat" and multiple "Cover" or maybe just a single "Cover" without the "Feat". Is there a way to check what it is, so "Feat" is handled one way and "Cover" a different way?

Title - Feat Someone - Feat Someone Else

should be replaced the same way, so:

Title (feat. Someone) (feat. Someone Else)

Try this:
$regexp('Title - Feat Someone - Feat Someone Else',(.*) - (.*) - (.*),$1 (\l$2) (\l$3))
(this would be valid for an action of the type "Format value", though)

You could setup an action group that caters for the various cases.
$regexp('Title - Feat Someone - Feat Someone Else',(.*) - Feat (.*) - Feat (.*),$1 (feat $2, $3)) -> Title (feat Someone, Someone Else)
$regexp('Title - Feat Someone - Feat Someone Else',(.*) - Cover (.*) - Cover (.*),$1 (Cover $2, $3)) -> Title (feat Someone, Someone Else)
and the last action would be
$regexp('Title - Feat Someone - Feat Someone Else',(.*) - (.*) - (.*),$1 (\l$2) ($3))

Thanks, I'm going to try it. One thing though: If there are multiple "Feat" or "Cover", they should all be in their own brackets, so if there are e.g. 2x Feat & 2x Cover, then it would be "Title (...) (...) (...) (...)"

Does this also work for e.g. 1x "Feat", 1x "Cover" or do I need an extra action for every case? If I need extra actions, is there a way to say something along the lines of:
Search for "- Feat " and put everything in brackets (including "feat.") up to the point where there's either another hyphen or the end of the title.
And then do another action just for "Cover".
Sorry, I don't know what's actually possible with Regex. Btw, is there a way to maybe add a little bit of Java code that tells mp3tag what to replace (instead of Regex)?

Instead of getting the sort of Swiss army knife for all cases, I would reduce the cases step by step.

If you want to replace, then use either the "Replace" action (a set of which can be joined in an action group) or use a $replace() statement (like $regexp()) in which you can define a number of pairs of search and replace terms. It does not join several pieces of the same type, though.

So, you see there are several ways to skin this cat. Use the one that suites you best.

Is there a more general way that does the following (to cover even the longer cases):

Put everything that starts with "- " and ends with " -" (or the end of the title if there isn't another hyphen) into brackets. Then repeat until the end of the title is reached. So basically your first suggestion but only for $1 and $2 and then repeated.

I could use this as first step, then just replace "(Feat " with "(feat. " in the second step.

Thanks, I now did it with your first suggestion:

Then added more like that, one action for just 2 parts, one for 3, one for 4 and one for 5. The last action replaces " (Feat " with " (feat. " (no regex).
Unfortunately this also replaces hyphens that aren't followed by "Feat" or "..... Cover" but there's probably no easy way around that, is there?

I'm now trying to find the remaining hyphens without any spaces but if I just type "-" into the filter field at the bottom, the list doesn't change (I know that there are still a couple left). Escaping ("-") doesn't help either. Any idea what to use to filter files with them?

Just the hyphen shows all the files that have the hyphen somewhere in all of the tags. So it is fairly likely that this is true for most of the files.
%title% HAS -
or even
%title% MATCHES -[A-z]*
to narrow down the selection.

1 Like

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