Add brackets around featured artists


#1

I would like to transform:
"Example Song feat. Someone"
into
"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:


#2

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


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

DD.20120705.1920.CEST


#4

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:


#5

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:
FROM >>> TO
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)


#6

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


#7

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)