Code: Select all
$thumbsmod = ""; $thumbssync = "";
$dat2 = formatlist(folderreport("files", "r", "<xythumbs>", , , "<crlf>"), "f", "<crlf>", "*.dat2");
if (confirm(quote("OK") . " to recreate and sync your your XYthumbs.txt file with<crlf>the thumbnnail data files after thumbnail cleanup, or<crlf 2>" . quote("CANCEL") . " to update XYthumb.txt only after cleanup.")) {$sync = "1";}
foreach($dat2file, $dat2, "<crlf>") {
$filehash = getpathcomponent($dat2file, "base"); //gets the base file name which is the "hash"
$dat2info = readfile("$dat2file", "b", 85, , 17); //reads each thumbnail ".dat2" file for the folder and thumbnail size
$thumbsfolder = gettoken($dat2info, 1, "*", "t"); //extract the folder
$thumbssize = gettoken($dat2info, "2", "*", "t"); //extract the thumbnail size
$filedate = property("#3", "$dat2file"); //obtains the file date
if !(exists($thumbsfolder)) { //adds a pre-checked "+" for inputselect for folders that do not exists.
$thumbsmod = $thumbsmod . "+" . $thumbsfolder . "|" . $thumbssize . "|" . $filedate . "|" . $filehash . "<crlf>";}
else {$thumbsmod = $thumbsmod . $thumbsfolder . "|" . $thumbssize . "|" . $filedate . "|" . $filehash . "<crlf>";}
if ($sync == "1") {
if !(exists($thumbsfolder)) { //adds a pre-checked "+" for inputselect for folders that do not exists.
$thumbssync = $thumbssync . "+" . $thumbsfolder . "|" . $thumbssize . "|" . $filehash . "<crlf>";}
else {$thumbssync = $thumbssync . $thumbsfolder . "|" . $thumbssize . "|" . $filehash . "<crlf>";}
}
}
$thumbsmod = formatlist($thumbsmod, "se", "<crlf>");
if ($sync == "1") {$thumbssync = formatlist($thumbssync, "se", "<crlf>");}
else {$thumbstxt = readfile("<xythumbs>\XYthumbs.txt");}
$sel_hash = inputselect("Select Thumbnails files to delete<crlf>based on folder location, thumbnail size and date.<crlf>Pre-checked folders no longer exist.", $thumbsmod, "<crlf>", 2, , 800, 800, "Thumbnail File Selection");
foreach($hash, $sel_hash, "<crlf>")
{
$hash = gettoken($hash, -1, "|"); //pull-out the hash only portion of line
delete 0, 0, "<xythumbs>\". $hash .".*"; //change 2nd parameter to "1" to prompt prior to deleting
if ($sync == "1") {$thumbssync = regexreplace($thumbssync, ".*".$hash.".*$\r?\n?");}
else {$thumbstxt = regexreplace($thumbstxt, ".*".$hash.".*$\r?\n?");}
}
if ($sync == "1") {
copytext "XYplorer Thumbs Index v1<br><date yyyy-mm-dd hh:mm:ss><br><br>";
copytext $thumbssync, a ;
$newThumbsTxt = "<clipboard>";
writefile("<xythumbs>\XYthumbs.txt", $newThumbsTxt, "o", "tu"); //writes a new XYthumbs.txt file based on actual thumb data and cleanup
status "XY thumbnail clean-up complete and XYthumb.txt regenerated and synced with thumbnail data files.";
}
else {
writefile("<xythumbs>\XYthumbs.txt", $thumbstxt, "o", "tu"); //updates the XYthumbs.txt based on cleanup
status "XY thumbnail clean-up complete and XYthumb.txt updated.";
}
Thanks,
Ken
XYplorer Beta Club