Conditional Formatting for Artist based on Album Artist

Thank you for your reply.

So should I introduce those as two new lines of code or am I supposed to replace existing?

Either $if($eql(%artist%,%albumartist%),1,0) could be implemented before Guess values, before Format value Filename/Title or replaces one or more of these?

Or was that just an example and the true coding is the second line you mentioned Format string: $if($eql(%artist%,%albumartist%),%feat_artist%,%artist%)?

Yes.

The sequence I see is:
First guess value so that the FEAT_ARTIST has a chance to get filled with the after-comma-data.
Now compare ARTIST and ALBUMARTIST - if they to not match, write ARTIST to FEAT_ARTIST otherwise leave FEAT_ARTIST as it is.
Now I would update the TITLE with [feat ...]
and finally rename the file with
%track% %title%
(as TITLE should contain the feat... part by now. In that order you do not have to add the feat... part twice: once to TITLE and once to _FILENAME)

Thank you.

So is this correct?

I don't think so.
Actions 1&2&3: ok
Action 4 should have FEAT_ARTIST as field to be formatted and not _FILENAME
Action 5 & 6 are a complete chaos of target fields and format strings.
Action 5 should format TITLE with format string: %title%[ (feat. %feat_artist%)]
Action 6 should format _FILENAME with format string: %track% _ %title%

Thank you, that makes sense.

It seems to be working for the most part.

However, it adds the track number to the filename again so for example '15 Lost Stars' turns into '15 15 Lost Stars (feat. Adam Levine)' and the artist name remains Adam Levine rather than being replaced by Album Artist.

The track number was not introduced by me.
Yes the ARTIST is still the old value as you did not take this into account

Right you are! Thank you.

Think I have cracked 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=FEAT_ARTIST
1=$if($eql(%artist%,%albumartist%),%feat_artist%,%artist%)

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

[#5]
T=5
F=_FILENAME
1=%track% %title%

[#6]
T=5
F=ARTIST
1=%albumartist%

I will continue to test. Does it look okay to you? Can you anticipate there being any problems?

I have. It seems if you inadvertently run the code on a file already amended it starts duplicating. Can this be stopped by using an if condition?

What gets duplicated?
And even if so: apply a filter that filters for FEAT_ARTIST MISSING because none of the untreated files should have that field.

The part in brackets:

If you run action #4 twice, you add another feat. artist.
That is why I suggested to filter.

You mean this filter? "$if($eql(%artist%,%albumartist%),1,0)" IS 0

I have that applied but it still brings up tracks which include feat in them (that I have not applied this code to).

Not sure how/why this is happening?

Have a look at the help about filtering and you will recognize the filter expression in

Okay, I will try to experiment with that.

In the mean time I have come up with the following when this scenario comes up:

[#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=FEAT_ARTIST
1=$if($eql(%artist%,%albumartist%),%feat_artist%,%artist%)

[#4]
T=5
F=ARTIST
1=%albumartist%

I was having problems with some folders including 'single' or 'album' or 'ep' or 'lp' in the folder name so I updated the code.

image

[#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=FEAT_ARTIST
1=$if($eql(%artist%,%albumartist%),%feat_artist%,%artist%)

[#4]
T=5
F=ARTIST
1=%albumartist%

[#5]
T=4
F=_DIRECTORY
1= \\(Album\\)
2=
3=0

[#6]
T=4
F=_DIRECTORY
1= \\(Single\\)
2=
3=0

[#7]
T=4
F=_DIRECTORY
1= \\(LP\\)
2=
3=0

[#8]
T=4
F=_DIRECTORY
1= \\(EP\\)
2=
3=0

Do you see this being problematic/is there a better way to code it?

If you replace text constants like "(Album)" then it is not necessary to use a regular expression (that is specifically good if you deal with patterns of variable contents) but just a plan "Replace".
I would use an action of the type "Format value" for _DIRECTORY to get a unified naming scheme. So instead of cutting away pieces of the string, rewrite it completely with e.g.
Format string: %year% - %album%

I have a specific and peculiar problem with Artist vs Album Artist. I used to have my cell phone music (~2000 tracks) all done up nicely with both fields correct. If the track is "Moves Like Jagger," then Artist was "Maroon 5 & Christina Aguilera" and Album Artist was "Maroon 5." HOWEVER, I bought a new car with Bluetooth and I can play music with my phone in my pocket and it's displayed on a dash panel. BUT ... the display shows Title and Artist only and it was Album Artist it was displaying. I experimented & found if there was no Album Artist tag, it would display just Artist. SO, I did an Mp3tag export and looked for all case where Artist & Album Artist were not equal and blanked out the Album Artist tag in those cases. Now my car display really shows me who the artist is! (It bothers my perfection gene, but if I ever wanted to fix the tags as they should be, it would be pretty easy.)

@NashvilleKit: what does your description have to do with the problem of moving the featured artist to the title?