Switching first and last name of Artist

If you know how many of these multi-value fields you have then you can use for the above example 2 action:
$regexp($meta(artist,0),'(.*?) (.*)','$2, $1')
$regexp($meta(artist,1),'(.*?) (.*)','$2, $1')

So, yeah, that sounds like you need to create something for a “B, A \ D, C” —> “A B \ C D”.

You’d need a different action for each number of collaborators and the separator ( \ ) would have to be identical for each one, or some sort of script written to change up to as many collaborators as you need ( F, E \ H, J ... etc.) but return null once the final separator is detected.

My collection didn’t have a bunch of those, so I found it easier to just edit those by hand. I never modified anything for that scenario.

I have a bunch of mp3s that have the tag listed as 'lastname, firstname' and want it 'firstname lastname' In searching for a solution I ran across this thread, however, I have an issue. The answer given by Flskydiver was:

Action: Format Value
Fromatstring: $regexp(%artist%,(.*)',' (.* ),$2 $1)

The change I want is

Warner, Steve ---> Steve Warner

What I get is

Warner, Steve ---> WarineS rteve

I triple checked the code given. What am I doing wrong?

Format string: $regexp(%artist%,'(.*), (.*)',$2 $1)

Take care of those artists that have the comma deliberately like Bell, Book & Candle, Earth, Wind & Fire, Emerson, Lake & Palmer etc.

Brilliant!!!! worked great, Thank You!!

Opening this up again as I have all of my files with AlbumArtist as Last, First.

With the help of those in this thread :index_pointing_at_the_viewer: :+1:, I have these expressions that copy AlbumArtist to AlbumArtistSort so they will sort that way, then transform AlbumArtist to First Last. Both in one action.

Format value "ALBUMARTIST": $regexp(%albumartist%,'(.*), (.*)',$2 $1)

Works well for most cases.

Anyone want to take a stab at an AlbumArtist in the form: Last, First & Last, First? The second comma messes things up.

I also want to be able to apply these expressions to a large number of files and don't want to have a lot of manual tasks. So the flow would be something like:

copy albumartist to albumartistsort
if albumartist is Last, First & Last, First, replace with Last, First & First Last
then ohrenkino's expression: $regexp(%artist%,'(.*), (.*)',$2 $1) from post 24

Accomplishing this would probably correctly treat 90%+ of cases. I'm sure I'll find another one or two that don't work with this.

So, it's the second of the three lines that I need help with.

Anyone? Many thanks

You could try
$regexp('Last, First & Last, First','(.*), (.*) & (.*), (.*)',$2 $1 & $4 $3)
as the second action, then the one that swaps without ampersand

Then I would filter for the files that they really match the patterns.
Earth, Wind & Fire would become Wind & Fire Earth with the first expression.
And this mixture applies to most other band names with a comma and an ampersand.
So I doubt that you can run it all on its own.


Thank you ohrenkino! :clap:t3:

I now have:


Here are example cases I identified so far that don't work (before / after)

Yamash'ta, Stomu / Yamash'ta, Stomu
Milteau, Jean-Jacques / Jean Milteau-Jacques
Earth, Wind & Fire / Wind Earth & Fire
Ndegéocello, Me'Shell / Me Ndegéocello'Shell
Scott-Heron, Gil / Scott-Heron, Gil
Coryell, Bailey, White / Bailey Coryell, White

I'll play with tweaking the expressions, but I think I am also at the point where I can search for and modify the edge cases manually so they will behave before doing mass operations.

This is an exact example that was given above by @ohrenkino to watch for. There are almost always fringe cases like these that are prime examples of why it isn't a good idea to run any operation on a huge number of files without knowing there could be undesired results.

But knowing that these do exist for such a small group, you can then make the necessary changes to these manually to have them conform to how you prefer them in your library.

I'd never run something like this over more than a few hundred tracks at a time. And even then only if you look through them before and after you run it. I like having all my artists and album artists separated with ; instead of stuff like: John Zorn, Laura Nyro & Johnny "Big Moose" Walker (featuring. Joni Mitchell Quartet).
Which is why I first treat the artist field with this:

The field I really care about is album artist tho, which is what I sort by last name.
The first action transforms:
John Zorn, Laura Nyro & Johnny "Big Moose" Walker (featuring. Joni Mitchell Quartet)
John Zorn; Laura Nyro; Johnny "Big Moose" Walker; Joni Mitchell Quartet

I've got another action to copy that to the album artist tag if there's garbage in the album artist tag I want to overwrite (I only put the main artist into the album artist field tho, not featured artists).


Regular expression:
([^; ]+\s?[^; ]+(?:\s?[^; ]+)?)\s(?!Trio|Quartet|Quartetto|Quintet|Sixtet|Sestetto|Septet|Octet|Ottetto|Orchestra|Chamber Orchestra|Ensemble)([^; ]+)

Replace matches with:
$2, $1

This then turns
John Zorn; Laura Nyro; Johnny "Big Moose" Walker; Joni Mitchell Quartet
Zorn, John; Nyro, Laura; Walker, Johnny "Big Moose"; Mitchell, Joni Quartet

If you keep or lose the "Quartet" part is up to personal preference. I usually delete it from the album artist as it's already in the artist field and only keep the name.

It's not perfect and I strongly advise that you try to understand every part of it before you use it on many files at once but for me it has greatly reduced the amount of manual editing of tags.
If anyone has suggestions to improve my actions, I'm always all ears.

Even though this action will certainly do as you say, I still think that it is a vain effort - as soon as you get "Zorn" into ARTISTSORT then all the other artists in that line will probably be ignored. So for a correct order, John Zorn would have been enough in most cases.

I have tried both versions of this and both have worked. Which is the correct version to use? I may not have come across something that may have an issue with either one, but that does not mean there is not something that will, so I want to use the proper one.

Also, for some reason I cannot run this with separators as I do with other similar scripts.

I created this action from other actions I found on the forum:



1= /


1=$regexp(%albumartist%,(.*)',' (.*),$2 $1)


2= /

But it will only give me one of the terms back in A B format.

Ex: lastname, firstname middlename / Miller, John Bob / Rolling Stone, The
is converted to:
firstname middlename lastname