AlbumArtistSort and ArtistSort - switch first and last names

Hi,

I have recently started converting my actions from Windows to Mac, and have discovered the actions I use for the sort fields only work partially. The source format copies, but the regex replace for swapping first and last names does not.

Please see the documentation on Mac's action to replace with regular expression
This shows that a different syntax from the WIndows version is used.

On the other hand: why do you need to swap as I bet that this field is really only used for sorting but the player then shows the contents of the non-sort field.
And that would mean that you don't need the swap but you only have to remove the first part of the name (or the "the"). I doubt that you really need the full name for sorting.
And this leads to the next advice: why use complicated and apparently incomprehensible expressions if the purpose does not require it. Keep it as simple as possible, would be my motto.

Please also identify the expression that doesn't work as expected and post it as a textual representation using copy&paste.

Probably only very few people on earth can spot what's wrong there by just having a hard look on it :smiley:

Try switching the second and third rule.

I use the sort fields to sort by LastName, FirstName as Music.app and iTunes default sorting is FirstName LastName

This is taken from the Windows action, which I basically just retyped by hand in Mp3Tag for Mac.

[#0]
T=5
1=%album%
F=ALBUMSORT

[#1]
T=7
F=%albumsort%
1=%albumsort% {%dummy%}

[#2]
T=7
F=%albumsort%
1=%albumsort% (%dummy%)

[#3]
T=4
F=ALBUMSORT
1=^The (.+)
2=$1, The
3=0

[#4]
T=5
1=%albumartist%
F=ALBUMARTISTSORT

[#5]
T=4
F=ALBUMARTISTSORT
1=^The (.+)
2=$1, The
3=0

[#6]
T=4
F=ALBUMARTISTSORT
1=^\\s+|\\s+$
2=
3=0

[#7]
T=4
F=ALBUMARTISTSORT
1=\\s{2,}
2= 
3=0

[#8]
T=2
F=ALBUMARTISTSORT
1=[ 
2=[
3=0|0

[#9]
T=2
F=ALBUMARTISTSORT
1= ]
2=]
3=0|0

[#10]
T=5
1=$regexp(%albumartistsort%,'\\sfeat.?\\s',';')
F=ALBUMARTISTSORT

[#11]
T=5
1=$regexp(%albumartistsort%,'\\svs.?\\s',';')
F=ALBUMARTISTSORT

[#12]
T=5
1=$regexp(%albumartistsort%,'\\swith?\\s',';')
F=ALBUMARTISTSORT

[#13]
T=5
1=$regexp(%albumartistsort%,'\\sand?\\s',';')
F=ALBUMARTISTSORT

[#14]
T=16
F=ALBUMARTISTSORT
1=;

[#15]
T=16
F=ALBUMARTISTSORT
1=,

[#16]
T=16
F=ALBUMARTISTSORT
1=&

[#17]
T=4
F=ALBUMARTISTSORT
1=^([^,[]+)\\s([^,[]+)$
2=$2, $1
3=0

[#18]
T=4
F=ALBUMARTISTSORT
1=^([^,[]+)\\s([^,[]+)\\s(\\[.+\\])$
2=$2, $1 $3
3=0

[#19]
T=8
F=ALBUMARTISTSORT
1=; 

[#20]
T=2
F=ALBUMARTISTSORT
1=Artists, 
2=
3=0|0

[#21]
T=5
1=%artist%
F=ARTISTSORT

[#22]
T=4
F=ARTISTSORT
1=^The (.+)
2=$1, The
3=0

[#23]
T=4
F=ARTISTSORT
1=^\\s+|\\s+$
2=
3=0

[#24]
T=4
F=ARTISTSORT
1=\\s{2,}
2= 
3=0

[#25]
T=2
F=ARTISTSORT
1=[ 
2=[
3=0|0

[#26]
T=2
F=ARTISTSORT
1= ]
2=]
3=0|0

[#27]
T=5
1=$regexp(%artistsort%,'\\sand?\\s',';')
F=ARTISTSORT

[#28]
T=5
1=$regexp(%artistsort%,'\\svs.?\\s',';')
F=ARTISTSORT

[#29]
T=5
1=$regexp(%artistsort%,'\\swith?\\s',';')
F=ARTISTSORT

[#30]
T=5
1=$regexp(%artistsort%,'\\sfeat.?\\s','; ')
F=ARTISTSORT

[#31]
T=16
F=ARTISTSORT
1=;

[#32]
T=16
F=ARTISTSORT
1=,

[#33]
T=16
F=ARTISTSORT
1=&

[#34]
T=4
F=ARTISTSORT
1=^([^,[]+)\\s([^,[]+)$
2=$2, $1
3=0

[#35]
T=4
F=ARTISTSORT
1=^([^,[]+)\\s([^,[]+)\\s(\\[.+\\])$
2=$2, $1 $3
3=0

[#36]
T=8
F=ARTISTSORT
1=; 

[#37]
T=5
1=%title%
F=TITLESORT

[#38]
T=4
F=TITLESORT
1=^The (.+)
2=$1, The
3=0

[#39]
T=7
F=%titlesort%
1=%titlesort% (%dummy%)

[#40]
T=7
F=%titlesort%
1=%titlesort% {%dummy%}

[#41]
T=5
1=%composer%
F=COMPOSERSORT

[#42]
T=4
F=COMPOSERSORT
1=^\\s+|\\s+$
2=
3=0

[#43]
T=4
F=COMPOSERSORT
1=\\s{2,}
2= 
3=0

[#44]
T=2
F=COMPOSERSORT
1=[ 
2=[
3=0|0

[#45]
T=2
F=COMPOSERSORT
1= ]
2=]
3=0|0

[#46]
T=16
F=COMPOSERSORT
1=,

[#47]
T=16
F=COMPOSERSORT
1=;

[#48]
T=16
F=COMPOSERSORT
1=&

[#49]
T=4
F=COMPOSERSORT
1=^The (.+)
2=$1, The
3=0

[#50]
T=4
F=COMPOSERSORT
1=^([^,[]+)\\s([^,[]+)$
2=$2, $1
3=0

[#51]
T=4
F=COMPOSERSORT
1=^([^,[]+)\\s([^,[]+)\\s(\\[.+\\])$
2=$2, $1 $3
3=0

[#52]
T=8
F=COMPOSERSORT
1=; 

That is understood.
What I would like to emphasize: If you have "Beatles" and "The Beatles" where the latter is switches to "Beatles, The" it actually does not matter that there was the "The" - you can simply leave that out.

If you have Katie Melua, then you don't need the "Katie" part as "Melua" is more or less unique. And this will apply to most other artists.
So the action could be much, much simpler as you only have to delete the first word and there you are: you have the term by which the track gets adequately sorted.

The other problem that I usually see: why have this extra effort at all?
There are so many names where you would not swap the first and last part. "Uriah Heep" would never be sought under "Heep", I guess. What about "Rolling Stones"? "New Kids on the Block"?
So you would have to define a lot of exceptions where the name should be swapped and where it shouldn't.
So my opinion (and you are entitled just as much to have your's) is: swapping is pointless.

Those particular instances are processed under an action specifically for groups.

Yes, sure they would have to.
The way you currently treat the names, this is mandatory.
My point was: is that necessary at all as the swapping does not make searching easier.
Some artist names are left as they are - so you can type them in the search as you speak them,
others have been swapped and there you have to type in the formerly second name.
IMHO this makes the whole thing more complicated.
Just another example sprang to mind: Frida Gold. Looks like a person's name but is a group in fact. Nobody in that group is called Frida. So, would that get treatment as a name to swapped or kept? And how to know the difference to "Gordon Lightfoot"?

OK, you will probably keep your workflow and sorting rules.

There is still a request to be anwered:

I don't know whether you realized that

is probably not the best approach if you have a look at the

which says that the syntax is a little different from the Windows version.

[#17]
T=4
F=ALBUMARTISTSORT
1=^([^,[]+)\\s([^,[]+)$
2=$2, $1
3=0
[#18]
T=4
F=ALBUMARTISTSORT
1=^([^,[]+)\\s([^,[]+)\\s(\\[.+\\])$
2=$2, $1 $3
3=0
[#34]
T=4
F=ARTISTSORT
1=^([^,[]+)\\s([^,[]+)$
2=$2, $1
3=0
[#35]
T=4
F=ARTISTSORT
1=^([^,[]+)\\s([^,[]+)\\s(\\[.+\\])$
2=$2, $1 $3
3=0

I'll check out the documentation

Lets focus on actions #17 and #18 which cover ALBUMARTISTSORT. What do you expect them to do and can you post an example where it fails?

I believe should be the one which swaps FirstName LastName to LastName, FirstName

I am pretty sure should cover when an artist has FirstName SecondName LastName to LastName, FirstName SecondName

eg. 3OH!3 feat. Katy Perry is only being changed to 3OH!3; Katy Perry, and not 3OH!3; Perry, Katy

I had a look at the expression used in #17 and it seems to me that an escape of the opening bracket in the first match group is missing. A correct expression would be

^([^,\[]+)\s([^,\[]+)$

The same applies to the expression using in #18

^([^,\[]+)\s([^,\[]+)\s(\[.+\])$

1 Like

#18 is simply a special case of #17 that handles parts in square brackets which shall remain at the end. They could be combined into a single action:

[#17]
T=4
F=ALBUMARTISTSORT
1=^([^,\\[]+)\\s([^,\\[]+)(\\s\\[.+\\])?$
2=$2, $1$3
3=0
  • in: John Doe [DJ]
  • out: Doe, John [DJ]
  • #6 is a less performant RX for $trim(%albumartistsort%)
  • #10 through #13 can be combined in a single expression, also fixing some typos (#15 and #16 could also be included):
[#10]
T=5
1=$regexp(%albumartistsort%,'\\s(feat\\.?|vs\\.?|with|and)\\s',';')
F=ALBUMARTISTSORT
1 Like

This worked, thanks. I mustn't have realised I missed the escape charaters when I initially did it... it was very late at night.

Also, is there a way in the sort fields to replace charatcters with graves, acutes, tildes, etc. with regular characters?

Yes, please open a new topic on, well, a new topic.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.