# Conditional Formatting for Artist based on Album Artist

**URL:** https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230
**Category:** Support
**Created:** [July 8, 2018, 7:09am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230 "2018-07-08T07:09:22Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 8, 2018, 7:09am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/1 "2018-07-08T07:09:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 8, 2018, 9:07am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/2 "2018-07-08T09:07:57Z")

</div>

See the help on scripting and boolean functions

> **[Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/#boolean-functions)**
>
> Documentation on Mp3tag's scripting functions. Mp3tag is the universal Tag Editor.

esp. $if2()

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

> [@Renaming](https://community.mp3tag.de/t/renaming/14613/12):
>
> All My files (without exception) have been named after the mask: "%track% - %artist% - (%album% \_ CD %discnumber%) -%year%".

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 8, 2018, 9:34am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/3 "2018-07-08T09:34:21Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 8, 2018, 2:03pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/4 "2018-07-08T14:03:06Z")

</div>

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.,\>,)

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 8, 2018, 3:24pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/5 "2018-07-08T15:24:29Z")

</div>

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](https://docs.mp3tag.de/customization/options/tags/mapping)

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.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 8, 2018, 5:50pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/6 "2018-07-08T17:50:00Z")

</div>

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.

> [@sheepdisease](#):
>
> Stereophonics, Tom Jones

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.

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 8, 2018, 7:32pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/7 "2018-07-08T19:32:42Z")

</div>

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?

![](https://community.mp3tag.de/uploads/default/original/2X/8/8b1ccb8432b37c3d6514a239899f3328868e3f1a.png)

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?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 8, 2018, 7:38pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/8 "2018-07-08T19:38:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 8, 2018, 7:45pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/9 "2018-07-08T19:45:47Z")

</div>

See this example for how artists are showing:

 ![](https://community.mp3tag.de/uploads/default/original/2X/4/43f61b4aa6810b985e0564272c48e27895b962ff.png)

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?

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 8, 2018, 8:00pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/10 "2018-07-08T20:00:30Z")

</div>

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:  
[https://community.mp3tag.de/t/move-featuring-from-artist-to-title/11096/108](https://community.mp3tag.de/t/move-featuring-from-artist-to-title/11096/108)

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 8, 2018, 8:49pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/11 "2018-07-08T20:49:11Z")

</div>

You were right! Thank you.

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

 ![](https://community.mp3tag.de/uploads/default/original/2X/1/1d88d6d8b824f1bf2fb18fd216cd4e387753b1e4.png)

It removes the second artist from the artist tag and places it in FEAT\_ARTIST:

![](https://community.mp3tag.de/uploads/default/original/2X/3/37977d9e7a9ec0dee9ff972c5fdaf168bb9b218d.png)

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:

 ![](https://community.mp3tag.de/uploads/default/original/2X/5/5e7ff693afefc9e1df507c91441a9e351fe2f621.png)

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 9, 2018, 5:04am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/12 "2018-07-09T05:04:42Z")

</div>

> [@sheepdisease](#):
>
> Should I leave it alone or is there a change

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.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [July 9, 2018, 8:45am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/13 "2018-07-09T08:45:56Z")

</div>

> [@ohrenkino](#):
>
> ARTISTS is definitely a user-defined field that you may have created

KODI seems to use ARTISTS according to [https://kodi.wiki/view/Music\_tagging#Tags\_Kodi\_reads](https://kodi.wiki/view/Music_tagging#Tags_Kodi_reads)

In the [KODI-Forum](https://forum.kodi.tv/showthread.php?tid=312293&pid=2570374#pid2570374) 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.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 9, 2018, 8:57am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/14 "2018-07-09T08:57:30Z")

</div>

> [@LyricsLover](#):
>
> KODI seems to use ARTISTS

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:

> [@ohrenkino](#):
>
> Unless you have a special purpose for the data in that field ... you can safely delete it.

The special purpose may be "Kodi".

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 9, 2018, 6:17pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/15 "2018-07-09T18:17:13Z")

</div>

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?

![](https://community.mp3tag.de/uploads/default/original/2X/1/1944a7c417fd5204e9f507e4021e3748942dd940.png)

![](https://community.mp3tag.de/uploads/default/original/2X/b/b03cd41514178939db7d1f799b4dce932664acf9.png)

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 9, 2018, 7:21pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/16 "2018-07-09T19:21:48Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 9, 2018, 8:57pm UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/17 "2018-07-09T20:57:56Z")

</div>

That is awesome, thank you!

It works correctly on these files.

 ![](https://community.mp3tag.de/uploads/default/original/2X/a/aa43517ed0fef0b35354eda0027bbffc666881a5.png)

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.

![](https://community.mp3tag.de/uploads/default/original/2X/9/98b5618aec9314aba8add07539d73e506f05929d.png)

> [#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%)

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 10, 2018, 5:28am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/18 "2018-07-10T05:28:34Z")

</div>

> [@sheepdisease](#):
>
> it changes the filename to Lost Stars (feat. ),

as I said:

> [@ohrenkino](#):
>
> If the string in title is correct we should have a look at the filename.

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.

---

<div class="post-metadata">

### Author: ![sheepdisease](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepdisease](https://community.mp3tag.de/u/sheepdisease)
#### Post date: [July 10, 2018, 5:49am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/19 "2018-07-10T05:49:01Z")

</div>

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?

 ![](https://community.mp3tag.de/uploads/default/original/2X/1/13f7e58cbf496809e33629742aefa9062c3f42eb.png)

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%)]

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 10, 2018, 5:57am UTC](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230/20 "2018-07-10T05:57:00Z")

</div>

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%

[Next page](https://community.mp3tag.de/t/conditional-formatting-for-artist-based-on-album-artist/42230.md?page=2)
