How to fix up Artist details by script

Use this forum for everything concerning script usage
Post Reply
SteveM
Newbie
Newbie
Posts: 4
Joined: Sat Jul 19, 2014 5:42 pm

How to fix up Artist details by script

Post by SteveM »

I am trying to write a script to fix up Artist information based on the following rule: (a) if the Album Artist is empty but Artist is not then copy Artist to Album Artist, or (b) if Artist is empty but Album Artist is not then copy Album Artist to Artist. The reason I want to do this is that many players show my tracks as Artist UNKNOWN when the details are in the Album Artist.

It's not easy from the help to understand the process; to me it appears to be (a) run the script and the information is updated in the grid, (b) after checking I got the results I wanted then click UPDATE and the grid is written back to the actual files. Is that how it works?.

Then there is the script: here is my script but after running it there are still lots of entries in the grid where Artist is blank but Album Artist is not so clearly it is not working...

Code: Select all

// This script looks at Artist and Album Artist and if one is blank and the other is not
// then it makes them the same

program SM_MergeArtists_2;

var
  artist: string;
  albumArtist: string;

begin

  if not tg_Init then exit; // no rows get out

  repeat
    tg_loadFile;
    artist := tg_GetField( 'Artist' );
    albumArtist := tg_GetField( 'Album Artist' );
    if (artist <> '') and (albumArtist = '') then begin
       tg_SetField('AlbumArtist', artist);
    end;

    if (albumArtist <> '') and (artist = '') then begin
       tg_SetField('Artist', albumArtist);
    end;

    gTag.SavetoFile( 0, false);

  until not tg_Skip;

end.
I also tried this version...

Code: Select all

// This is a script to ensure that where we have one and only one of Album Artist / Artist then
// the one we have is copied to the missing one

program MergeArtists;

var
  artist: string;
  albumArtist: string;
  _BAD_ARTIST = 'UNKNOWN*';

  // we will use the advanced delphi MatchesMask function for this

begin

  if not tg_Init then exit; // no rows get out

  repeat

    artist := tg_GetField( 'Artist' );
    albumArtist := tg_GetField( 'Album Artist' );
    if (not MatchesMask( artist, _BAD_ARTIST ))  and (MatchesMask( albumArtist, _BAD_ARTIST )) then begin
       tg_setField( 'Album Artist', artist);
    end;

    if (not MatchesMask( albumArtist, _BAD_ARTIST ))  and (MatchesMask( artist, _BAD_ARTIST )) then begin
       tg_setField ('Artist', albumArtist);
    end;

  until not tg_Skip;

end.

Any help would be much appreciated.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: How to fix up Artist details by script

Post by jtclipper »

This can be done without a script using the conditional %variables.

Make sure you set the following values in the template

Code: Select all

Artist value:        %?A;AA%
Album artist value:  %?AA;A%
Conditional variables check the values in a linear fashion and use the first non empty value.

After that hit scan or apply if you already scanned, observe that the values are OK then hit update

SteveM
Newbie
Newbie
Posts: 4
Joined: Sat Jul 19, 2014 5:42 pm

Re: How to fix up Artist details by script

Post by SteveM »

That certainly did the trick. Thanks very much for the reply and the tip.
Kind Regards
Steve

SteveM
Newbie
Newbie
Posts: 4
Joined: Sat Jul 19, 2014 5:42 pm

Re: How to fix up Artist details by script

Post by SteveM »

Am I right in thinking I also need to UNTICK the file name box? It seems loads of my tracks were given a new file name and now iTunes reports loads of tracks that it can't find - I just want to change the tags and not impact the names or folders of anything.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: How to fix up Artist details by script

Post by jtclipper »

Click the down arrow next to the update button and select tags only , the icon will change also so you don't have to recheck each time

Post Reply