Move ft. artist to title

Not sure why the Regular Expression sticky is locked for further contribution..but I figured I'd share an action group that I created to move featured artist information from the Artist or AlbumArtist tag to the Title tag.

It was a bit trickier than I thought. I found a caveat with MP3Tag's "$regexp()" scripting function, where--if there is no match--then it defaults to replacing the selected format field with the regexp string "x". So I needed to add a little more logic to work this out.

Action Group: Fix ft. artist - Format the Title from Artist or AlbumArtist

# Check if a test regexp replace on Title from Artist featured artist match yields a diff result than = AlbumArtist, and proceed with replace. Else, if it's the same, then this means that the match failed and just keep the same Title.
Action: Format Value
Field: TITLE
$if($eql($regexp(%artist%,(?i:featuring|feat|ft|,|\s?/|\sx\s),$char(0)),%artist%),%title%,$regexp(%artist%,(.+?)((?i:featuring|feat|ft)\.?\s+?|,\s?|\s?/\s?|\sx\s)(.+),%title% '(ft. $3)'))

# Check if a test regexp replace on Title from AlbumArtist featured artist match yields a diff result than = AlbumArtist, and proceed with replace. Else, if it's the same, then this means that the match failed and just keep the same Title.
Action: Format Value
Field: TITLE
$if($eql(%artist%,%albumartist%),%title%,$if($eql($regexp(%albumartist%,(?i:featuring|feat|ft|,|\s?/|\sx\s),$char(0)),%albumartist%),%title%,$regexp(%albumartist%,(.+?)((?i:featuring|feat|ft)\.?\s+?|,\s?|\s?/\s?|\sx\s)(.+),%title% '(ft. $3)')))

# Clean Artist tag
Action: Format Value
Field: ARTIST
$regexp(%artist%,(.+?)(\(?(?i:featuring|feat|ft)\.?\s+?|,\s?|\s?/|\sx\)?)(.+),$1)

# Clean AlbumArtist tag
Action: Format Value
Field: ALBUMARTIST
$regexp(%albumartist%,(.+?)(\(?(?i:featuring|feat|ft)\.?\s+?|,\s?|\s?/|\sx\)?)(.+),$1)

# Trim after all done (cannot do this on $1 in the expressions above for some reason)
Action: Format Value
Field: ARTIST
$trim(%artist%)

Action: Format Value
Field: ALBUMARTIST
$trim(%albumartist%)

Hope this helps someone else out there!

1 Like

Also, you might find that there is extra space or closing parenthesis in the Title when you are done.
I wasn't able to modify the original format expressions to deal with this.
Here is another action group to clean that up.

Action Group: Clean title

Field: TITLE
Action: Format
$trim(%title%)

Field: TITLE
Action: Replace with Regular Expression
Replace: ((\)|\s)){2,}
Replace with: $1

Oh, one more thing to mention-

This matches commas "," as a featured artist. So if you have "Doors, The" or "Sheeran, Ed" then you will get some bad results.

Be sure to check this first or change the format expression if you don't want that.

5 posts were split to a new topic: Remove newline / linebreak characters from tag fields