Main discussion forum
gelat
Newbie
Posts: 35 Joined: Sat Nov 20, 2010 10:02 pm
Post
by gelat » 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.
jtclipper
Administrator
Posts: 772 Joined: Tue Aug 10, 2010 12:04 pm
Post
by jtclipper » Fri Feb 02, 2018 8:19 pm
Please test the following script on some test folder it should work OK.
Make sure 'Filename' is selected on the drop down box of the update button
Code: Select all
Program MainEditor;
var
i: integer;
sTmp:string;
begin
if not tg_init then exit;
i := 1;
sys_SetStatusText( 2, IntToStr( tg_GetRowCount ) );
repeat
tg_LoadFile;
sys_SetStatusText( 1, IntToStr( i ) );
sys_SetStatusText( 3, gTag.Filename );
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';
gTag.ClearPictures; // remove any existing
gTag.LoadPicture( ExtractFilePath( gTag.Filename ) + 'folder-600.jpg' );
if UpperCase( gtag.album ) = 'SINGLE' then begin
gTag.sortalbum := '';
gtag.track := '';
gtag.AlbumArtist := 'Various Artists'
sTmp := gTag.Artist + ' - ' + gTag.Title;
end else begin
gtag.AlbumArtist := gtag.artist;
sTmp := gTag.Track + ' - ' + gTag.Artist + ' - ' + gTag.Title;
end;
//Update tags
gTag.SaveToFile( 0, false );
//set filename
tg_setField( 'Rename', tg_setField( 'Rename', sTmp + '.' + gTag.FileExt ); );
Inc( i );
until not tg_skip;
tg_Update; //trigger the update button ->Select Filenames only
end.
gelat
Newbie
Posts: 35 Joined: Sat Nov 20, 2010 10:02 pm
Post
by gelat » Mon Feb 12, 2018 6:50 pm
That worked. Thank you!
gelat
Newbie
Posts: 35 Joined: Sat Nov 20, 2010 10:02 pm
Post
by gelat » Sat Feb 17, 2018 5:07 pm
Ia there a way to modify this so it works when BOTH is selected? Right now it only works on FILENAME, which causes manual global tag edits on the right panel to not work.
jtclipper
Administrator
Posts: 772 Joined: Tue Aug 10, 2010 12:04 pm
Post
by jtclipper » Sun Feb 18, 2018 9:08 am
You can try this one it will basically update the grid and set it ready for the update, it will however remove the 'extra' fields and update the picture directly in the file beforehand
Code: Select all
Program MainEditor;
var
i: integer;
sTmp:string;
begin
if not tg_init then exit;
i := 1;
sys_SetStatusText( 2, IntToStr( tg_GetRowCount ) );
repeat
sys_SetStatusText( 1, IntToStr( i ) );
sys_SetStatusText( 3, gTag.Filename );
//work directly on the file
tg_LoadFile;
gTag.extrafieldsremove;
gTag.ClearPictures; // remove any existing
gTag.LoadPicture( ExtractFilePath( gTag.Filename ) + 'folder-600.jpg' );
gTag.SaveToFile( 0, false ); //Update tags
//work in the grid
//set tag fields
tg_setField( 'Comment', '' );
tg_setField( 'Language', '' );
tg_setField( 'Composer', '' );
tg_setField( 'Publisher', '' );
tg_setField( 'Copyright', tg_getField( 'Year' ) );
tg_setField( 'EncoderSettings', '' );
tg_setField( 'URL', '' );
tg_setField( 'Lyrics', '' );
tg_setField( 'OrigArtist', '' );
tg_setField( 'OrigYear', '' );
tg_setField( 'BPM', '' );
tg_setField( 'Disc', '' );
tg_setField( 'MediaType', '' );
tg_setField( 'sortAlbum', '[' + tg_getField( 'Copyright' ) + '] - ' + tg_getField( 'Album' ) );
tg_setField( 'MediaType', '' );
tg_setField( 'Conductor', '' );
if (UpperCase( tg_getField( 'Genre' ) ) = 'POP/ROCK') or (tg_getField( 'Genre' ) = 'ALTERNATIVE') then begin
tg_setField( 'Genre', 'Rock' );
end;
if UpperCase( tg_getField( 'Album' ) ) = 'SINGLE' then begin
tg_setField( 'sortAlbum', '' );
tg_setField( 'Track', '' );
tg_setField( 'AlbumArtist', 'Various Artists' );
sTmp := tg_getField( 'Artist' ) + ' - ' + tg_getField( 'Title' );
end else begin
tg_setField( 'AlbumArtist', tg_getField( 'Artist' ) );
sTmp := tg_getField( 'Track' ) + ' - ' + tg_getField( 'Artist' ) + ' - ' + tg_getField( 'Title' );
end;
//set filename
tg_setField( 'Rename', sTmp + '.' + gTag.FileExt );
Inc( i );
until not tg_skip;
//comment out if you want to do some maunal editing or use the template and do the update afterwards
tg_Update; //trigger the update button
end.
gelat
Newbie
Posts: 35 Joined: Sat Nov 20, 2010 10:02 pm
Post
by gelat » Sun Feb 18, 2018 5:39 pm
thx. worked.