Replace albumartist tags having multiple values with single value

My goal is to identify all files with more than one value for the albumartist tag and replace the values with a single value. I was able to put together the following filter for identifying files with multiple albumartist tag values:
NOT ("$meta_sep(albumartist,_)" IS artist_name_here)

I can run this by hand for each artist folder by copying the artist name and putting it where I have artist_name_here, but this is not ideal. Ideally, I'd be able to use a variable to reference the artist. The problem is, I want to use the root folder name as the artist (see folder structure below). The artist tag value isn't always what I'm looking for because some files also have multiple values for the artist as well. I also can't simply use the folder name of the file in question because that would yield the album name (most of the time). I also have no idea how to write a filter expression for that.

My end goal is to be able to import all my files in mp3tag, identify the ones that have multiple albumartist values, and replace them all at once by feeding a variable representing the root folder name into the tag panel. I'm not all that familiar with mp3tag but I assume scripting would be the way to go, but I honestly don't have the knowledge to do that.

Thank you to anyone who can help me!

My folder structure is as follows:
Artist -> Album -> Track
For instance:
Adele -> 19 -> Best For Last.flac

There are occasions where there may be a few tracks in the root directory of the artist, such as:
Adele -> Best For Last.flac
There are also occasions where an album is broken down into multiple CDs and the structure would be as follows:
Artist -> Album -> CD1 -> Track.flac

You could use
"$meta(artist,1)" PRESENT
which shows all files that have more than 1 ARTIST field.
This would relieve you from the bother of getting the artist name from somewhere else.

To treat multi-value fields there are actions to

  • remove duplicate fields
  • merge duplicate fields.

I would look at the multi-value fields and their data first before I replace anything.

As far as I understand you, you want to replace ALBUMARTIST with the value of %_parent_directory% if there are several ALBUMARTIST-fields?

I would load all my folders without the mentioned exceptions into MP3Tag. You can do that by holding the CTRL-key and drag them into MP3Tag from the windows-explorer.
Then you can apply a filter for only multiple ALBUMARTIST-fields:
"$meta_sep(albumartist,\\)" HAS \\

Mark all displayed files and treat them with the Converter Tag->Tag or an equivilant action of the type Format Value:
Field: ALBUMARTIST
Format String: %_parent_directory%

The converter gives you a preview of the expected result.

Thank you both for your responses.
@ohrenkino My goal here is to have the accurate artist information in the ARTIST field, meaning if there are multiple artists then there will be multiple values for that tag. However, ALBUMARTIST needs to always be relating to the folder in which the file is contained, that artist specifically. This is purely for organizational purposes.
Branching off of your idea, is it possible to create a format string that does the following?

  1. Identifies files that DON'T have multiple ALBUMARTIST values
  2. Grab an ARTIST value at random from the filtered results, its value will surely be the value we're looking for
  3. Refilter for files that do have multiple ALBUMARTIST values and replace based on the ARTIST value we acquired in step 2.
    I'm not sure if the actions for removing duplicates field or merging duplicate fields would help me here

@poster
I love your thinking. I did as you mentioned. The filter worked perfectly, and the new value for ALBUMARTIST looks to be correctly populated! Looks like I have to use "%_parent_directory%".
Is it possible to further filter the results to exclude the exception? For instance, excluding any files which have a filepath containing CD1, CD2, etc. I suppose we'd have to somehow exclude \CD*.

It is not possible to apply a filter in an action.
You could use $IF() and it derivates to define a situation. But I think for the purpose to copy the data from ARTIST to ALBUMARTIST, it would be enough to use
"$meta(albumartist,1)" PRESENT
and get all the files with several fields of the type ALBUMARTIST.
MP3tag does not compare data of different files. You can only compare data of properties and fields that are part of the current file.
So storing some kind of artist from a previous file is not possible.

See here for %_parent_directory% being a valid property variable:

@ohrenkino Thank you for the response! Right now I'm using this filter expression to include only files that have multiple ALBUMARTIST values and do NOT have \CD*\ in their path.
"$meta_sep(ALBUMARTIST,\\)" HAS \\ AND NOT %_PATH% MATCHES \\CD.*\\
For some reason the MATCH part of the express just doesn't produce the intended results. Based on my testing, I think there's an issue with the NOT before the MATCHES. Am I not properly negating the %_PATH% MATCHES \\CD.*\\ part?

In a regular expression .* means "any number of characters. Also, the expression should be enclosed in inverted commas.
Perhaps
AND NOT %_PATH% MATCHES "CD\d+"
leads to better hits.