Help on my rename script?
Posted: Sun Jan 28, 2018 6:53 pm
I am in the edit panel, and I am both tagging and renaming here (set to update both). I am NOT using the rename template in the bottom right corner, as I need it to be dependent on the tags in the file. The problem is that I'm not sure what command updates the tags and then renames the file, as I seem to get one or the other. I'm not sure when to use tg_update, tg_apply, tg_refreshrow or gtag.savefile. Help?
Code: Select all
Program MainEditor;
var
i: integer;
sTmp:string;
sExt:string;
begin
if not tg_init then exit;
i := 1;
sys_SetStatusText( 2, IntToStr( tg_GetRowCount ) );
repeat
sTmp := tg_getfield( 'Rename' );
tg_LoadFile;
sExt := '.' + gtag.FileExt;
gtag.extrafieldsremove;
gtag.Comment := '';
gtag.language := '';
gtag.Composer := '';
gtag.publisher := '';
gtag.copyright := gtag.year;
gtag.encodersettings := '';
gtag.URL := '';
gtag.Encodedby := '';
gtag.Lyrics := '';
gtag.OrigArtist := '';
gtag.OrigYear := '';
gtag.bpm := '';
gtag.discnumber := '';
gtag.mediatype := '';
gtag.sortalbum := '[' + gtag.copyright + '] - ' + gtag.album;
gtag.conductor := '';
if gtag.genre = 'Pop/Rock' then gtag.genre := 'Rock';
if gtag.genre = 'Alternative' then gtag.genre := 'Rock';
sys_SetStatusText( 1, IntToStr( i ) );
sys_SetStatusText( 3, gTag.Filename );
gTag.ClearPictures; // remove any existing
gTag.LoadPicture( ExtractFilePath( gTag.Filename ) + 'folder-600.jpg' );
//tg_Apply;
if gtag.album = 'Single' then
begin
gTag.sortalbum := '';
gtag.track := '';
gtag.AlbumArtist := 'Various Artists'
sTmp :='';
sTmp := gTag.Artist + ' - ' + gTag.Title;
tg_RefreshRow;
end
else
begin
gtag.AlbumArtist := gtag.artist;
tg_RefreshRow;
sTmp := gTag.Track + ' - ' + gTag.Artist + ' - ' + gTag.Title;
End;
//tg_RefreshRow;
//tg_Update;
sTmp := sTmp + sExt;
tg_setfield( 'Rename' , sTmp );
//tg_Apply;
gTag.SaveToFile( 0, false );
tg_update;
i := i + 1;
until not tg_skip;
end.