Add brackets around featured artists

I would like to transform:
"Example Song feat. Someone"
"Example Song (feat. Someone)"

I already Googled it and used this code, but replaced "ARTIST" with "TITLE" (and, for aesthetic reasons, "Feat." with "feat.").

The only problem was that it put ')' after any song, not just those songs that had featured artists. I obviously could select only the songs that I need to transform, but I figured some of you might've seen this problem before and already have a solution for this.

Anyhow, hope you guys have the answer. :slight_smile:

Yes, as it says in one of mentioned posts: use a filter.

Caution: This link is misleading. It does not link to Google.


It does now. (Even so: it still linked to Google, you just need to wait.)

Well, guess I'll have to use a filter.

Thanks. :slight_smile:

First use a filter like:
TITLE" HAS "feat."

Then create an action:
Begin Action Group _Script Test#TEST

Action #1 Actiontype 5: Format value Field ______: TITLE Formatstring: $regexp(%TITLE%,'(.+)[^\(]((?=feat\.).+)','$1 ($2)')

End Action Group _Script Test#TEST (1 Action)

Examples of results:
Example Song feat. Someone >>> Example Song (feat. Someone)
fgdgf feat. fsdfsdfl;jyigihkhiutt8y9o >>> fgdgf (feat. fsdfsdfl;jyigihkhiutt8y9o)
Example Song (feat. Someone) >>> Example Song (feat. Someone)
Example Song feat Someone >>> Example Song feat Someone **Doesn't match 'feat'
Example Song Someone >>> Example Song Someone
Example Song (Someone) >>> Example Song (Someone)

This works splendidly!
(It really isn't even necessary to run a filter: all the other songs remain unchanged.)

yes it searches for anything but '(' and then has a positive lookahead for 'feat.' and unless it finds them then its doesn't match and therefore replace unwanted files.

PS. The filter is handy when you have say 10,000 files and running actions on unwanted files is a waste

EDIT: (screen-shot of how the regexp works)