Conditional Formatting for Artist based on Album Artist

I have a number of albums which contain multiple artists for individual songs.

Because the album is by a particular artist, even if another artist is featured, I want the artist to be that of the album (files are stored in music>artist>album>tracknumber trackname) and anyone else featuring on a particular track should appear only in the filename (music>artist>album>tracknumber trackname (feat. other artist).

For example, at the moment I have a Stereophonics album which includes songs they have done with other people like Tom Jones. Under Artist it lists all Artists separated by a comma (Stereophonics, Tom Jones).

If I were to create an action to include the featured artist (in this case Tom Jones), it would also include the name of the artist (Stereophonics).

[#0]
T=5
F=_FILENAME
1=$num(%track%,2) %title% $regexp(%artist%,(.+?) ((?:featuring|feat|ft).?) (.+),'$1 ($2 $3)')

music>artist>album>tracknumber trackname Stereophonics, Tom Jones.

In terms of conditional formatting, surely there must be a way to omit the album artist from the filename and replace with the following?

music>artist>album>tracknumber trackname (feat. Tom Jones)

Whilst performing this action, the artist could be changed to album artist.

See the help on scripting and boolean functions

esp. $if2()

Also see the special function of the square brackets to specify optional output for the filename. eg. in this thread

Thank you for your reply.

I have read through but cannot figure out how to use boolean in this instance to get the output required.

I really need someone to help me code this so that I can begin to understand.

coming back to the original problem:
Do you have the featured artist(s) separated by a unique identifier or is it just a comma?
(then beware of groups like Earth, Wind & Fire; Dave Dee, Dozy, Beaky, Mick and Titch and so on).

you can filter for files where ALBUMARTIST does not match the ARTIST:
"$if($eql(%artist%,%albumartist%),1,0)" IS 0

I would then first of all move all featured artists to a user-defined field like FEAT_ARTIST.
Use an action of the type "Guess value" for that.
Now, with the more structured data, you do more or less anything you want, like add the featured artists to the title.
Use an action of the type "Format value" for that.
A small piece of advice here: if you use unique separators straight away like e.g. the <>, then it is easy to treat the data in these separators.
So the title might be
Mama told me not to come <& Tom Jones>
If you want to get that as "feat" in the filename, use
$replace(%title%,'<&,feat.,>,)

Thank you for your reply.

The featured artist(s) are separated by a comma only. The filter you gave me works well to identify files which need fixing.

I started trying to build this code but after attempting to implement I am still clueless.

Firstly, I started looking into user-defined fields but don't really understand, although I did read through Mapping – Mp3tag Documentation

I created a custom column named FEAT_ARTIST which shows %artist%. Then I started creating a custom action:

[#0]
T=7
F=%artist%
1=%albumartist%, %artist%

This is far as I got before I could not get any further.

Could you please document the actions in plain language?
I do not want to look up which code stands for which action and which option for each action.

Creating a column named FEAT_ARTIST with the contents of ARTIST does progress your endevour.
Instead, the action of the type guess value distributes the contents of the source to named target fields. You create a user-defined field when you use the syntax for fields but do not use a reserved fieldname - in this case it would be %feat_artist%.
So to split the existing artist e.g.

so that Stereophonics stays in ARTIST but Tom Jones goes to FEAT_ARTIST, use as
SOurce: %artist%
target:%artist%, %feat_artist%
Now have a look at the extended tags (Alt-T) and see that you have a field FEAT_ARTIST with the contents Tom Jones and the field ARTIST is now only filled with Stereophonics.

Thanks again for your reply.

Tried this and checked extended tags by using the keyboard shortcut but couldn't see FEAT_ARTIST anywhere?

Based on what you have said I think I have it set up correctly?

Also, I have noticed in some instances that the order of artists who contributed to a track can be wrong. For example, one of the Stereophonics songs lists Tom Jones first, which would mean once this rule works, it removes his name and adds (feat. Stereophonics).

Is there a way to prevent this happening? Again, avoid duplicating the album artist regardless of the order of artists showing?

the setup looks ok provided you really have that kind of separator - it is taken absolutely literally.
So if you do not have a blank behind the comma, it will fail.
So please check that again and then see if you then succeed.

Looking at the other problem, that with the swapped artists: again: MP3tag does not read or understand the contents of fields. It compares patterns.

See this example for how artists are showing:

Am I missing something else other than the guess value action to get this working properly?

Surely the program can compare albumartist with artists populating in the artist tag? Surely it can also recognise if any value within artist matches album artist to make this work?

as I described earlier, the guess value action is only one of a number of steps. THe other steps then rely on the FEAT_ARTIST field to be filled.
Apparently this is no way for you - although I still think it would be easiest.
I also supplied a way to compare strings - perhaps you find inspiration there.
And also there is a huge thread with more than 100 posts that deals mainly with the shifting around of featuring artists - you already had a look at it:

You were right! Thank you.

I tested it again and it seemed to function as described:

It removes the second artist from the artist tag and places it in FEAT_ARTIST:

I will have another look at the rest of your suggestions to see if I can get this working correctly.

I find it strange that there are two fields though, with one being artist (Maroon 5) and artists being artists (Maroon 5/Gwen Stefani). I don't think I have ever noticed that before. Should I leave it alone or is there a change that Itunes or Windows Media Player/Groove will move the tracks around the Music directory/not show albums where I expect if I don't set it to the main artist?

I also need to figure out a way to stop the script from running beyond removing the second, third etc artist from the artist tag when the filename is already correct:

ARTISTS is definitely a user-defined field that you may have created due to a typo - or whatever. Unless you have a special purpose for the data in that field (like you have now for the user-defined field FEAT_ARTIST) you can safely delete it.
This also applies to FEAT_ARTIST when you have transferred the featured artist to the field where you want to have that name.
If in the future you want to get the featured artist back to be moved some other field, it is advisable to have a unique separator between the (I guess) title and the featured artist name.
I personally use <& Name> which is 2 characters shorter than "feat." and does not pose the case problem if you have run a case conversion action afterwards.

KODI seems to use ARTISTS according to https://kodi.wiki/view/Music_tagging#Tags_Kodi_reads

In the KODI-Forum they explain it like this:

The other way to tell v17 Kodi that "The Chainsmokers & Coldplay" is two artists is to use the ARTISTS tag with "The Chainsmokers / Coldplay". Kodi gives priority to the ARTISTS tag to identify individual artists, you could always add this tag to the file you get from itunes.
...
If you just tag with ARTIST = "The Chainsmokers & Coldplay", with no Musicbrainz Id tags, or ARTISTS (only v17 makes use of that) then Kodi will create an artist called "The Chainsmokers & Coldplay". But of course it will be unable to find any art or additional info for this artist.

It still remains a user-defined field.
If KODI found that workaround ... other programs use "semicolon blank" in the standard field ARTIST, ALBUMARTIST and COMPOSER to separate participating artists... others ignore that and also user-defined fields.
Some programs may cope with multi-value fields (iTunes does).
As I said:

The special purpose may be "Kodi".

1 Like

Thanks for the replies.

I have spent some time rereading and trying to put together working code but at the moment I am getting syntax errors or it just completely deletes the filename/trackname.

How do I get this to function according to my previous description? What have I done wrong?

Do not use the \ in a format value action as this may lead to multi-value fields.
I doubt that the $replace() is actually the correct way as you left out the value that should be used instead of that what is found.
Also I think that you got the order the wrong way round: you use data from TITLE for _FILENAME that is not there yet as the "formatting" for TITLE is the step after dealing with _FILENAME

To add a string to a field use a syntax like this:
Format value for TITLE
Format string: %title% feat. %feat_artist%

If the string in title is correct we should have a look at the filename.

That is awesome, thank you!

It works correctly on these files.

It has made me wonder though if there is a way to make it work when the Artist tag differs from the Albumartist tag to include any name in those instances.

In the screenshot above, there is a track where it says the artist is Adam Levine. If you run the rule on that file, it changes the filename to Lost Stars (feat. ), So ideally, if the Artist tag is blank, it does not amend the filename or title, but if there is an artist which differs from the albumartist it includes it.

[#0]
T=4
F=TRACK
1=^(\D+)/\D+
2=$1
3=0

[#1]
T=5
F=TRACK
1=[$num(%track%,1)]

[#2]
T=7
F=%artist%
1=%artist%, %feat_artist%

[#3]
T=5
F=_FILENAME
1=%track% %title% (feat. %feat_artist%)

[#4]
T=5
F=TITLE
1=%title% (feat. %feat_artist%)

as I said:

For the filename use as format string:
%track% %title%[ (feat. %feat_artist%)]
This will add the part with the feat_artist only if there is data in the field.

Thank you for coming back to me on that.

I have tested it on the same track and it seems to behave as expected. However, there must now surely be a way to implement what i have described into this?

Album Artist is Maroon 5. Artist is Adam Levine. How do we introduce a check of the two fields and insert Artist name if different to Album Artist name into the featuring part? Once this has been done, it should change the Artist to the Album Artist.

[#0]
T=4
F=TRACK
1=^(\D+)/\D+
2=$1
3=0

[#1]
T=5
F=TRACK
1=[$num(%track%,1)]

[#2]
T=7
F=%artist%
1=%artist%, %feat_artist%

[#3]
T=5
F=_FILENAME
1=%track% %title%[ (feat. %feat_artist%)]

[#4]
T=5
F=TITLE
1=%title%[ (feat. %feat_artist%)]

You can recycle the $IF() from the filter:
$if($eql(%artist%,%albumartist%),1,0)
would become part of the format value action for FEAT_ARTIST:
Format string: $if($eql(%artist%,%albumartist%),%feat_artist%,%artist%)

I would spare me another comparison of ALBUMARTIST and ARTIST as by now it should be clear that ALBUMARTIST and ARTIST should always show the same (and if they don't - "take this") so simply add an action of the type "Format value" for ARTIST
Format string: %albumartist%