Help dealing with albumartistsort

I basically need one script that does the following:

  1. Sets the albumartistsort extended tag field to be equivalent to the "Album Artist" field unless
  2. there is a "The" in which case, I would like the albumartistsort field to read "Album Artist, The".

Is this possible?

To make it easier: I am pretty sure that the "The" is not necessary any more to sort better.

So I would suggest that you use an action of the type "Format value" or Convert>Tag-Tag for ALBUMARTISTSORT
Format string: $regexp(%albumartist%,^The ,)
This simply
Please watch out for artists that seem to need the "The" like "The The" or "The Band", "The XX".

I don't understand what this does:
$regexp(%albumartist%,^The ,)

Have you tried it?
It removes any leading "The " and leaves the rest.
And as I said: if you add the trailing "The" will not make any difference for sorting.

See also here:

The other problem that I have is a lot of albumartistsort fields are something like "Drake, Nick" and I would like it to be "Nick Drake.
I can see how your script would solve my problem for the "The" though. But how do I solve the first problem? All my Album Artist fields are the way I want them, I just wanted to port over what is in Album Artist to albumartistsort.

This is a simple Convert Tag-Tag and set Albumartistsort to be Albumartist.

But why would you want these to be identical? It defeats the purpose of having the sort field. It is intended to allow you to have the Albumartist displayed as expected but sorted under a different way. Removing articles like A, An, and The are the most obvious ones in English. Your other example of Drake, Nick is to have that artist sorted under the D's as you would find them in store.

Otherwise you can leave this field u filled and most players and media managers will default back to the standard field.

My suggestion would copy ALBUMARTIST to ALBUMARTISTSORT in all cases and only for those with a leading "The" it would leave out that article.

And in general for the problem of copying fields, there is a post in the FAQs:

My suggestion would copy ALBUMARTIST to ALBUMARTISTSORT in all cases and only for those with a leading "The" it would leave out that article

How do I do that if-then construction?

For what would you need such an if-then construction?
The regular expression works without that.
The condition is "built-in", so to say, as the regular expression returns the original string if the pattern has not been found.

See the documentation on regular expressions:

It would be extremely tricky to separate the artists that have swapped names from those that actually have a comma as they consist of a list.
E.g.
Bell, Book and Candle,
Earth, Wind and Fire
Dave Dee, Dozy, Beaky, Mick & Tich

Would turn into something like "Book Bell and Candle" or "Bell and Candle Book", "Earth, Wind and Fire" into "Wind Earth and Fire" or "Wind and Fire Earth" ...

The easiest way would be to delete all ALBUMARTISTSORT fields and start from scratch. And "scratch" would mean: fill only those ALBUMARTISTSORT fields that really have to be different from the ALBUMARTIST field.

You could filter for files with a starting "The " with
%albumartist% MATCHES "^The "