// =================================================================== // ======== Godfather/bootlegzone.com post-tagging ======== // ======== file rename automation script ======== // =================================================================== // ======== This script does the post-tagging file ======== // ======== renaming work after using the ======== // ======== bootlegzone.sco script I made. ======== // ======== Enjoy! ======== // ======== ======== // ======== Latest version can always be found here: ======== // ======== http://www.pharaohweb.com/blog/?p=777 ======== // ======== ======== // ======== dave ======== // =================================================================== Program Automate; var fileLength, iRow: integer; tstStr, pathStr: string; begin on_Apply; iRow := 1; //do a bunch of string manipulations to get the character length of where the files //live on disk, as Windows counts full path towards total filename 256 char limit pathStr := sys_getCurrentDirectory(); pathStr := Copy(pathStr, 1, Length(pathStr)-1); //get rid of the last directory slash pathStr := Copy(pathStr, 1, RPos('\',pathStr)); //get rid of the current dir name, as we'll rename it later on //loop through the grid rows, after applying the tag info with on_Apply above, and //check the total charact length of the ID3 track title string, artist name string, //and album title string. if the combo of all these character strings is greater //than 256 characters (since, in Windows NTFS, the folder name and file name length //cannot exceed 256 chars), then we have to truncate the filename. i chose to //truncate offending filenames to 60 chars, you can change that value to your //own liking if need be. while (iRow <= on_getGrdRowCount()) do begin on_setGrdRow(iRow); tstStr := on_getGrdField('Title'); fileLength := Length(on_getArtist) + Length(on_getAlbum) + Length(on_getGrdField('Title')) + Length(pathStr); if (FileLength >= 256) then //the filename length plus foldername length is greater than 256 //chars, and we need to truncate the filename begin sys_MessageDlg('Track ' + InttoStr(on_getGrdRow()) + ' title longer than 256 characters (' + InttoStr(fileLength) + '), will be truncated (yes/no buttons do nothing).', 2, 0 ); tstStr := Copy( on_getGrdField('Title'), 1, 60 ); tstStr := sys_RegexReplace( tstStr, '(\|)', ';', false); //replace pipes in ID3 medley with semicolons for filename tstStr := sys_RegexReplace( tstStr, '(:)', '-', false); //replace colons in ID3 medley with semicolons for filename if on_getGrdRow() < 10 then begin on_setGrdField('Rename', '0' + InttoStr(on_getGrdRow()) + ' ' + tstStr + '.mp3') end else begin on_setGrdField('Rename', InttoStr(on_getGrdRow()) + ' ' + tstStr + '.mp3') end; on_RenameThis; end //the filename length plus foldername length is less than 256 //chars, so just rename the current grid row file and move on else begin on_RenameThis; end; //increment the row counter and move along to the next file iRow := iRow + 1; end; end.