How to fix up Artist details by script
Posted: Tue Apr 19, 2016 7:54 am
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...
I also tried this version...
Any help would be much appreciated.
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.
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.