First Name Last Name with any frailing words to Last Name, First Name and Trailing words

I have been using this Action to switch a simple First Name Last Name to Last Name, First Name:

Replace with regular expression:
Regular Expression
Replace with:
$2, $1

One reason why I use this is because it will not modify names already in the Last Name, First Name format. Ex: Brel, Jacques William remains Brel, Jacques William with the above action.

How can I modify it to work with trailing words behind a first and last name? So Alton Ellis & The Lipsticks would become Ellis Alton & The Lipsticks.

I have tired these variations that I saved:
Transform Artist from "A B" to "B, A" or "A B C" to "C, A B"
Ex: "John Smith" to "Smith, John" or "John Michael Smith" to "Smith, John Michael"

Regular Expression: (.*) (.*)
Replace with: \2, \1

Transform Artist from "A B C" to "B C, A"
Ex: "John Smith Jones" to "Smith Jones, John"

Regular Expression: (.?) (.)
Replace with: $2, $1

Transform Artist from "A B C" to "B, A C" where "C" is any suffix you like following a two word name

Regular Expression: (.?) (.) (.*)
Replace with: $2, $1 $3

But they neither suit my purposes or work. The last action should
work but I keep getting Alton Elli&, s The Lipsticks

In the end I want to incorporate this into the following action, which I use to convert names with multiple fields separated by a " / "
Artist 2 Album Artist AND Artist Sort; A B or Preposition A B to B, A, (Preposition to end) BOTH SPANISH & ENGLISH (Not affected by Forward Slash Does not affect Surname, 1st Name).mta (1.0 KB)

Didn't you participate in a thread that deals more or less with the problem of lists with a slash in them?

And to be honest: the swapping of names ... does it really make sense? There are so many exceptions that the swapped names in the end do not ease the access to the artist.
Any decent player will search for artist name parts so it does not matter which structure the name has.
In which field do you want to swap the names? I hope, only in the ~SORT fields as otherwise it will become a strange thing to look for Uriah Heep under "H" but Pink Floyd under "P" - because I guess that you will only swap name parts for names that look like first name, last name.
And would it make sense to see, "Stones, Rolling", together with "Stone, Joss".
The only exception I see is the removal of articles for names where the artists themselves did not keep a straight line, like "Beatles" and "The Beatles".

Uh, just found a nice name: East 17 - that would be sorted to "17, East"?
It does not make sense to me.
And if you say, well that is an exception that stays as it is - what qualifies exceptions? So it would need complicated rules as to when a name is swapped and when it isn't - when the simplest rule would be: take it as the artist calls himself.

1 Like

Thanks for your input, ohrenkino. I am only using this for sorting fields and only using this for First Name Last Name artist, such as Brian McKnight, which at times as featuring or accompanying artists, which is why I would need this. So Brian McKnight and Boys II Men would turn to McKnight, Brian and Boys II Men. Things like East 17, will just stay East 17. I already have things that work for turning The Rolling Stones to Rolling Stones,The, even though I know most players will do this on their own.
Though I appreciate the nudge to reconsider my logic, the question is not why I am doing this, but rather how to accomplish my goal. There should be a way to have the fist two words to go from A B to B, A no matter what trails the two words so that ABC could turn to B, A C, but I am not sure why the ones I wrote in my notes do not work.
I have something for doing the reverse.
Any help in modifying the first code above so that it could do this will be greatly appreciated. I just can't wrap my head around it though I am still actively trying. :thinking:

As I have to invest time and effort for your individual problem I think it is a valid excursion to question why all the effort should be spent at all. I think I have made my point clear: I don't think it is worthwhile to swap name parts around.

Coming to your problem:
$regexp('Brian McKnight and Boys II Men',(.*?) (.*?) (.*),'$2, $1 $3')
results in
"McKnight, Brian and Boys II Men"

1 Like

OK, I get it. Sorry if your took offense :grimacing:, it was not my intention to offend. As I said, I do appreciate you trying to point out that something may not be necessary. :+1:

It is not about finding things but rather the way they are displayed, and formatting things so that they list in the way one would like. Maybe I am being overly fastidious, I do tend to sweat the details. Anyway, I hope that helps explain why I want to perform this function.

Thank you so much for your help on trying to solving this. Your help has been invaluable and I sincerely appreciate your time and effort very much. Question and challenge my motives all you want. :grinning: You have changed my thinking on a thing or two.

The one thing your solution does not address that the first function listing does, is that it does not ignore or leave alone names that are already in the Last Name, First Name format, so I cannot just perform this function grossly, but have to be more careful. That is perfectly fine, but it would be great if I could modify

Replace with regular expression:
Regular Expression
Replace with:
$2, $1

to perform this function it would be awesome.

Another thing I was hoping to add is to use this in an action that would work for simple A B and also for A B C, where you could instruct the action to perform

Replace with regular expression:
Regular Expression
Replace with:
$2, $1

when there are two terms and use your proposed function when there are more than 2 terms.
Still, this works for now. I can just use it less grossly and more judiciously.

I was reading your comments on the First Name Last Name thread, which I am scouring, once again, for solutions to my problem, and I want to let you know that just because I am switching names for artist like Steve Miller and Stevie Ray Vaughn & Double Trouble, I am NOT changing Pink Floyd to Floyd, Pink or East 17 to 17, East. That would not make sense. But bands like The Rolling Stones will be turned to Rolling Stones, The. Also in Latin music, you have bands that like Trio Matamoros, that released albums under Cuaterno Matamoros and Septeto Matamoros. If I did not place the Trio or Cuaterno after the Matamoros, separated by a ", " these albums and songs would not be grouped together. There is a method to my madness. Basically I am following the organization principles of a library. The scripts we were discussing were not meant to be used grossly across all songs but rather selected ones.

I know you probably think this is a waste of time, and you may be right, but there has to be a reason why sorting fields exist and this whole system was created in the first place. The question is if that initial reason is pertinent in today's world.

Definitely a reason exists for the sorting fields. For those that prefer to have their library sort John Lennon under "L", this is an important field to have. For those that prefer the same to sort under "J" there is no need for the sort fields in their case. The option exists for those that choose to use it. [Note that there are limited music library managers and players that support these as well, so choose the relevant ones based on your use case.]

1 Like

Libraries, as far as I can remember, worked with cardboard cards to ease the access to information.
You had just limited ways to find what you are looking for.
Then, in the 80s, the first online libraries opened and mainframe computers allowed full text search which was a milestone.
Nowadays, any decent player has a search function that looks into all supported fields - and I am absolutely sure that

as a single search word would produce all the

in a nice group.
And perhaps even those tracks where one of the Matamoros was composer.
So, IMHO, I do not see any reason any more to spend the extra effort to fill the ~sort fields esp. if this leads to problems like the one with several names.
But everybody is free to organize his or her own collections the way they want.
What I do see as a problem: if a solution is presented that apparently cannot be maintained and has to be discussed back and forth - is that worth the effort? And what will happen in a couple of months time when it becomes more and more difficult to remember what the whole expression did?
In such cases of doubt I would always opt for the simpler solution.


You make very good points that have me thinking. Of course I would love not have to engage in this activity. Still, libraries still sort and store things in the same manner as they did pre-computers. Maybe they are reluctant to change or are invested in an archaic systems. I too have fallen prey to resisting change that ended up being more convenient (paperless billing). This may be the case here as well. You really have me thinking. Of course everyone is free to do as they wish, I am just trying to do things properly, perhaps to a fault.

Yes, a search function may render the point moot, but what if you just want to go down a list and see things organized? It is nice, but is it worth all the effort?