Regex issues when rearranging multivalue tag

I‘m using MP3Tag on a MacBook and try to generate artistsort from artist. Both fields are used with multiple values.

So artist:

Oscar Peterson\\Dizzy Gillespie\\Clark Terry\\Eddie "Lockjaw" Davis\\Niels-Henning Ørsted Pedersen\\Bobby Durham

should result in artistsort:

Peterson, Oscar\\Gillespie, Dizzy\\Terry, Clark\\"Lockjaw" Davis, Eddie\\Ørsted Pedersen, Niels-Henning\\Durham, Bobby

If I export the artist tag, I can rearrange it with

sed -E 's/(^|\\)([^\\ ]+) ([^\\]+)(\\|$)/\1\3, \2\4/g' output.txt > input.txt

properly.

But the action import from file in MP3Tag will only import the first value (Peterson, Oscar).

On the other hand I failed to set up an action in MP3Tag first copying artist to albumartist (this works) and afterwards reformatting the tag Artistsort with the regex command I‘m using in sed because of the missing Parameter -E.

Did you find another way to generate a multiple sort-tag from the original tag? Any ideas are welcome.

You would have to show us the data and the applied function.
AFAIK the action imports the whole text filed into just 1 field in all the selected files.
If you want to get a single record from the text file into a specifc audio file and distribute the data into several fields, you would have to use Convert> Text file - Tag.

You can use an action Format tag field for ARTISTSORT using

$regexp($metasep(artist,\\),'(^|\\)([^\\ ]+) ([^\\]+)(\\|$)','$1$3, $2$4')

@ ohrenkino: I used the function (<CTRL + E>) with "$meta_sep(ARTIST,\)" to export the artists of one album.

This results in a file output.txt like this:

Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen
Toots Thielemans\\Joe Pass\\Niels Henning Ørsted-Pedersen

After seding with

sed -E 's/(^|\)([^\ ]+) ([^\]+)(\|$)/\1\3, \2\4/g' output.txt > input.txt

input.txt looks like:

Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels
Thielemans, Toots\\Pass, Joe\\Henning Ørsted-Pedersen, Niels

The next step was to re-import input.txt with an action (I believe)

Import text file "$meta_sep(ARTISTSORT,\\)"

but right now I'm struggling how to open input.txt ?

@Florian:

Your regex-string solved my problem and I don't even need to export / import the tags to textfiles.

Thank you very much both of you for your support! :star_struck:

Best Regards

kauwelhoner