Script: Thumbnail Maintenance
Posted: 21 Aug 2013 16:04
Hi,
I looked at the size of my XY "thumbnails" folder the other day and couldn't believe how large it had grown. On the laptop it was 1.4 gig and on the desktop it was over a 1.5 gig...way too much picture taking on trips I suppose.
Don had mentioned earlier in this thread that he may institute some thumbnail cleanup tool when he gets some time. In the meantime more as a learning tool for me, I'm attempting to come up a with a script that would look a the XYthumbs.txt file located in XY's thumbnails folder and allow the user to look at the entries and then select those thumbnail files (based on the locations and thumbnail sizes) which he wishes to delete. Note: It would be nice to grab the "date" from the actual files and put that in the inputselect list along side of the associated folder location and thumbnail size, but maybe later.It actually is working (well most of it
), but after deleting the appropriate hash.dat2 and hash.dbit files, I'd also like to remove the associated lines ($sel_hash) from XYthumbs.txt file and then write the new file, but I'm having problem coming up with the filter using "formatlist" (or any other method for that matter). I'm not sure if I need a foreach to filter out each removed line? Could someone point me in the right direct to do this? Thanks. I've temporarily put in a confirmation in the deletion process which I'd eliminate when the script is completed. For testing just hit "no" so you're not deleting the files until the script is done.
Thanks,
Ken
The latest version 1.20 is available here viewtopic.php?p=204361#p204361
I looked at the size of my XY "thumbnails" folder the other day and couldn't believe how large it had grown. On the laptop it was 1.4 gig and on the desktop it was over a 1.5 gig...way too much picture taking on trips I suppose.
Don had mentioned earlier in this thread that he may institute some thumbnail cleanup tool when he gets some time. In the meantime more as a learning tool for me, I'm attempting to come up a with a script that would look a the XYthumbs.txt file located in XY's thumbnails folder and allow the user to look at the entries and then select those thumbnail files (based on the locations and thumbnail sizes) which he wishes to delete. Note: It would be nice to grab the "date" from the actual files and put that in the inputselect list along side of the associated folder location and thumbnail size, but maybe later.
Code: Select all
$selected = "";
$thumbstxt = readfile("<xythumbs>\XYthumbs.txt");
$sel_hash = inputselect("Select Thumbnails files to delete<crlf>based on thumbnail size and folder location.", $thumbstxt, "<crlf>", 2, , 700, 600, "Thumbnail File Selection");
foreach($hash, $sel_hash, <crlf>)
{
$hash = gettoken($hash, -1, "|"); //extract the hash only portion of line
$selected = $selected . $hash . "<crlf>"; //for testing only
delete 0, 1, "<xythumbs>\". $hash .".*"; //using "1" to confirm deletion for testing only, but will change to "0" to avoid all the prompts when multiples selected
}
//text $selected; //for testing only
$newthumbs = formatlist($thumbstxt, "f", "<crlf>"), !"$sel_hash"); //trying to filter out the lines for the files which were deleted.
text $newthumbs;
//writefile("<xythumbs>\XYthumbs.txt", $newthumbs);
Thanks,
Ken
The latest version 1.20 is available here viewtopic.php?p=204361#p204361