Deletion of Thumbnails

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
outskirter
Posts: 10
Joined: 01 May 2014 01:45
Contact:

Deletion of Thumbnails

Post by outskirter »

If I empty one folder that previously contained images for which XYplorer had created thumbnails, is there an easy way of deleting the thumbnails from the cache? Obviously I wouldn't want to delete all of my thumbnails, otherwise I'd have to regenerate them. Up 'til now I've been opening XYThumbs.txt to figure out which of the thumbnails are no longer valid. Sometimes a lot of them are left behind, and they're kind of awkward to find due to those long hexadecimal file names. :shock:
Last edited by outskirter on 29 Jun 2014 05:33, edited 1 time in total.

binocular222
Posts: 1419
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Deletion of Thumbnails

Post by binocular222 »

http://www.xyplorer.com/xyfc/viewtopic. ... =15#p90973

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.";
     }
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

outskirter
Posts: 10
Joined: 01 May 2014 01:45
Contact:

Re: Deletion of Thumbnails

Post by outskirter »

Thanks, binocular222. I must have missed that post, since I tend to avoid scripting discussions, finding them too technical. I'm using XYplorerFree, anyway, so scripts are not an option. What I had in mind was opening a folder, going to the thumbnail config dialogue, directly or by right-clicking the thumbnail button on the toolbar, and issuing a command to clear the thumbnails for the current folder.
Last edited by outskirter on 29 Jun 2014 05:33, edited 1 time in total.

binocular222
Posts: 1419
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Deletion of Thumbnails

Post by binocular222 »

Without script:
- Open \\XYplorer\Data\Thumbnails\XYThumbs.txt
- Find any invalid/empty folder path
- Delete the relevant *.dbits files
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

outskirter
Posts: 10
Joined: 01 May 2014 01:45
Contact:

Re: Deletion of Thumbnails

Post by outskirter »

binocular222 wrote:Without script:
- Open \\XYplorer\Data\Thumbnails\XYThumbs.txt
- Find any invalid/empty folder path
- Delete the relevant *.dbits files
Thanks, that's exactly what I've been doing all along.
Last edited by outskirter on 29 Jun 2014 05:34, edited 1 time in total.

binocular222
Posts: 1419
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Deletion of Thumbnails

Post by binocular222 »

Honestly, you should consider upgrading to full version.
Scripting brings XY to a totally new level of speed, automation and usability. Catalog is nice too.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply