Automating Changes to Artist Values

I am undertaking a major re-tagging exercise and wish to standardise Artist entries in the format 'Last name, First Name'. At present a huge number of entries are in the format 'First name, Last Name' and I want to change all of these so that. for example, 'John Coltrane' becomes 'Coltrane, John'.

Is there a way I can set up an action to automate this?

Read there ...
Regular Expressions
Regular Expressions
Multiple value artist tag to multiple value artistsort
Need help with regex for ARTISTSORT

Action: Format value
Format string: $regexp(%ARTIST%,'([^;]+)(\s[^;]+)','$2, $1')

"Rolling Stones"
" Stones, Rolling"

"John Lewis;Mick Jagger;Ringo Harrison"
" Lewis, John; Jagger, Mick; Harrison, Ringo"


Many Thanks, DetlevD. Unfortunately at present the Action leaves me with a leading space at the beginning of the new name, which of course means that my control point now puts it at the beginning of the alphabetical sort. I have experimented but can't work out how to amend the format to ensure that there is no leading space in the new name.

Have a look at the trim functions $trim, $trimLeft, $trimRight to remove surrounding spaces.

Try this ... for only one artist name

$regexp(%ARTIST%,'([^;]+)\s([^;]+)','$2, $1')

Try this ... for multiple artist names

$trimLeft($regexp(%ARTIST%,'([^;]+)(\s[^;]+)','$2, $1'))

... or ...

$trimLeft($regexp(%ARTIST%,'([^;]+)\s([^;]+)',' $2, $1'))


That worked fine, DetlevD. It will save me an enormous amount of work. Many Thanks for your help.