Script: Thumbnail Maintenance

Discuss and share scripts and script files...
Stef123

Re: Script: Thumbnail Maintenance

Post by Stef123 »

Thank you Ken,
I am on the road, not enough material to test under "real" conditions, but something weird seems to be going on my Win7 notebook: "Allow multiple instances" is enabled, I made sure of that. The tray shows no indication that a 2nd instance is up and running. Win Task Manager, however, shows 6 entries of XYplorer.exe.
klownboy wrote:The script has barely started its work when that message comes out. It hasn't even opened the 2nd instance of XY yet.
Good to know. For about 12 seconds the status bar keeps changing with path information on what it's doing, so when "report done in # ms" comes on, it misleads the uninformed user into thinking it's "done". It seemed a bit too soon, yes, but then again, I don't have much material to work with at the moment, and wasn't aware that a 2nd instance won't speed it up (naturally, makes sense) :oops:
klownboy wrote:I'll provide a status message that will tell you, "Refreshing thumbnail cache for $sel_folder...please wait". Where $sel_folder is the folder for which it's currently building a cache so it will change the message for each foreach loop/folder it's working on. This way you'll know what's going on status wise
:appl: :appl:
klownboy wrote:That line you quoted is the script line which runs the second instance of XY and rebuilds the cache folder by folder. It's run for each and every folder and it's subs. So it doesn't surprise me what you got when you tried to escape.
So how would I cancel out? Does it mean I have to shoot down all running XYplorer processes?
klownboy wrote:You can do some things in the original XY while the script is working.
Hm, to some extent, yes. But here's the thing: Pressing ESC elsewhere (even outside XY) will bring up "Script terminated by ESC" and the error line quoted in my other posting (run "cmd /c <xy> ""$path"" ...") upon subsequent ESC-triggers.

I appreciate your offer to provide another one-instance-only alternative. Makes me feel safer.
Thank you
Stef

EDIT: I just realized my tray is configured to show some important system stuff only. No wonder I didn't get to see the other instances :oops:

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Script: Thumbnail Maintenance

Post by klownboy »

Hi Stef123, Thanks for the comments. I'll work on the other version where you can see the thumbnail refresh happening. I think many people do feel safer seeing what's going on. Though the background version should work the same only you don't see it.

The command line, run "cmd /c <xy>... uses the "/new" switch for XYplorer. With that switch you don't need to have "Allow multiple instances" checked off in configuration. I do not. Though I don't think it should make any difference- at least I hope not. Try disabling it just in case it does for some reason. The XY help bible states that "/new" overrides those settings.

The run "wait" parameter "2" in the foreach loop should complete each run of the refresh or rebuild before moving to the next folder. So I'm not sure why you had six XY icons in the tray. When I run the script and then watch the tray, I can see an XY icon come up then go away (when it's done it's work on one folder) then it comes back up showing that it's now working on the next folder, etc. Sorry it's not working for you. I'd like to figure out why because it's working fine for me.

Sorry for the confusion on my comment,"...you can do some work in XY". You can navigate, run programs, use tabs and built-in CTBs but you can run anything that involves another script like another CTB that runs a script.
Thanks again,
Ken
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Stef123

Re: Script: Thumbnail Maintenance

Post by Stef123 »

klownboy wrote:So I'm not sure why you had six XY icons in the tray.
Meanwhile I found out (or tend to think so) that these are leftovers from each time I press ESC and crash the script.
klownboy wrote: You can navigate, run programs, use tabs and built-in CTBs but you can run anything that involves another script like another CTB that runs a script.
Not sure whether PFA assocations also classify as "script". But even if I press ESC to exit out of, say JPEGView, it crashes the script running in the background.

In any case, I'd feel a lot safer to have this option to cancel the running script at any point. Guess I'd happily live with a single-instance version of your maintenance tool, if you don't mind?
Thank you
Stef

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Script: Thumbnail Maintenance

Post by klownboy »

I haven't forgot about this script. I'm been working on an update...actually sending way too much time on it, but WTH scripting can be fun. :whistle:
Ken
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Stef123

Re: Script: Thumbnail Maintenance

Post by Stef123 »

Take your time, no rush.
Already I save lots of time and brain CPU-cycles by using the existing versions of your script.

Thanks for keeping us posted and for keeping this thing alive.
Stef

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Script: Thumbnail Maintenance

Post by klownboy »

Hi, version 1.1 finally, I updated script to provide more error control and safe guards as well as new options. The script will also prompt you to ask if you've made any recent changes to your thumbnail dimensions which have not been saved (not a common occurrence) and will give you the opportunity to save. It will also ask if you'd rather not be asked again for future runs. I hope you don't mind highend, I used (stole) your technique to save the user preference in the script itself from your ShowLibraries script.

I mentioned on another thread that thumbnail maintenance can be a chore hopefully not so much with this script. The thumbnail cache will remain in the <xythumbs> folder even if you delete a folder full of images. And, maybe even more surprising is that the cache will also remain if you delete all the files in a folder even after a complete rebuild/refresh using cid #501. As previously noted, thumbnails will remain in the cache if you move or rename pictures out of the folder so it will pay off to rebuild or refresh the folder's thumbnail cache. This new version will besides flagging folders which no longer exists will also flag folders which are now empty of files yet still have a cache such that the old cache can be deleted. It's too difficult to sufficiently explain the menu items "on the menu" so here goes...sorry for the length.

Menu Options
- Foreground Thumbnail Maintenance -
  1. "Thumbnail Cache Clean-up [by folder using cache DB]" - This option is strictly based on what's present (thumbnail cache) in your thumbnail database files. From here you can see the folders having a cache, the thumbnail sizes, dates, cache size, etc. and based on that information check off any cache(s) you want deleted. As mentioned this option will pre-check any folders which no longer exist or which are now empty of files such that they can be easily deleted.
  2. "Refresh Thumbnail Cache [by folder using cache DB]" - This menu item provides you with a listing as above of all the thumbnail cache files. It will also tell you if you have cache(s) that need to be deleted because the folder no longer exists or is empty and re-direct you to delete them before continuing. With this option you can check off a number of folders in which you want the cache rebuilt.
  3. "Thumbnail Cache Clean-up [current folder & subs]" - This will delete all existing the thumbnail cache from the current folder and all its subs and update the DB by comparing all the folders with those in the thumbnail cache. Remember each thumbnail size for a particular folder will have its own cache file (i.e., "dat2" and "dbits" files).
  4. "Build Thumbnails Cache [current folder only]" - This menu item will build a new database of thumbs for the current folder and all its subs. It makes no difference if there were some folders which had pre-existing cache or not. It will (actually in this case it's XYplorer itself is doing the work) either write new thumbnail cache or write over ones (i.e., "dat2" and "dbit" files ) that already existed in the XY thumbnail folder. New in this option, you can now select multiple thumbnail sizes to build or refresh and you will receive a report on the before and after size of the thumbnail database file for each thumbnail size.
  5. "Build Thumbnail Cache [current folder && subs]" - Same as the option above, but this one will rebuild thumbs for all sub folders as well and again it will also allow you to select multiple thumb size per folder. It will prompt you for your thumb size selection before each sub folder so you may not want to use this option if you have many sub folders. It too will provide you a report of the before and after thumbnail database files size for each folder and in each thumbnail size.
  6. "Refresh Existing Thumbnails Cache [current folder & subs]" - The last new menu item will do the same thing as the option above, build a thumbnail cache for the current folder and all its subs, but in this case it will only re-build the cache for the folders that already have thumbnail cache and only in the thumbnail sizes that were already present. So it's not making any new ones for any of those folders that didn't have a cache, only rebuilding the cache for the folders that had one. I think this option is very handy to keep the database trim. Remember thumbs will stay in the DB when you move, delete and rename images so if you've done a lot of that, it may be much larger than it needs to be.
  7. "Build && Delete Thumbnails Cache [current folder && subs]" - This can be a handy option in that it will refresh or build the thumbnails in the size of your choice for the current folder and all it's subs with little interaction required other than initially selecting the thumbnail size. It will also delete any other cache(s) for any thumbnail sizes other than the chosen one. I built a bit more smartness into this option and the equivalent background version too, in that it determines if there is no thumb database for the folder at the given thumb size, it will "goto" the folder which will generate the thumbs in itself without the additional need to accomplish a refresh using cid #501.
  8. "Delete Entire Thumbnail Cache" - Careful, as stated it deletes the entire thumbnail cache after a prompt.
- Background Thumbnail Maintenance -
  • Same as the above foreground operations similarly titled and icons, but performs the maintenance in a 2nd instance of XY.
thumbnailMaintenance_cap.PNG
thumbnailMaintenance_cap.PNG (24.67 KiB) Viewed 3486 times
ThumbnailMaintenance_v1.10.zip
(320.35 KiB) Downloaded 270 times
Much thanks to Highend, SammaySarkar, PeterH, Marco and Stef123 for help and ideas. Please let me know if you have any issues.
Thanks,
Ken
Last edited by klownboy on 28 Aug 2014 13:38, edited 1 time in total.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

lian00
Posts: 365
Joined: 09 Jul 2014 17:12

Re: Script: Thumbnail Maintenance

Post by lian00 »

Thanks a lot for your work.
Windows 10 64 bits

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Script: Thumbnail Maintenance

Post by bdeshi »

Wow, a new janitor! :mrgreen:
:appl: :appl: :appl:

and thanks for the credits :) though you didn't have to.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Script: Thumbnail Maintenance

Post by klownboy »

Thanks lian00 and Sammay. Maybe that's what I should have called it, Thumbnail Janitor. :)
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Script: Thumbnail Maintenance

Post by bdeshi »

:D

\ed\ Multiple sizes in one go is already my 2nd most used feature, (first one is cleanup!) /ed/

Hey, don't understand the last option: "Build & Delete Thumbnail Cache"
It just seems to build cache. Should it be called "Delete & Rebuild"?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Script: Thumbnail Maintenance

Post by klownboy »

SammaySarkar wrote:It just seems to build cache. Should it be called "Delete & Rebuild?
It was hard to properly name all these menu items. See the explanations in the text for that option title. It will "BUILD" the thumbnails in the size you select (this one allows only one size) and it will also DELETE the thumbnail cache(s) for all other sizes thumbnails other than the one selected. I like that option 'cause it ensures you are besides rebuilding the cache, it is also "cleaning house" on any other cache(s) in other thumbnail sizes you may still have lying around (remember other size thumbnails cache(s) for a particular folder are in a different cache file).
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Script: Thumbnail Maintenance

Post by bdeshi »

Yes, the inputselect's WARNING made me think of the last line of my post.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Script: Thumbnail Maintenance

Post by klownboy »

SammaySarkar wrote:Should it be called "Delete & Rebuild"?
Yes, when it comes down to it, I should have called it Delete and Rebuild. I'll tweak it on the next update. Maybe it was my reverse thinking because in the script I actually built the thumbs for the size selected and then deleted those that were not. In looking back it would have been much easier to script if I had simply blindly deleted all thumbs in the folders and its subs and then rebuilt in the size thumbs selected...oh well. :whistle:
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Stef123

Re: Script: Thumbnail Maintenance

Post by Stef123 »

Wow! Still catching my breath and rubbing my hands in delight. This is awesome, klownboy. What I appreciate most in the new version:
- thumb sizes are taken into account, having the choice to select any combination of them :biggrin: , getting reports with size info is nice too :appl:
- feedback in the status bar :wink:
- having both options, fore- and background operation, very reassuring to know and choose what method is being used :biggrin:
- refresh existing thumbs cache only :idea:

Your script is not just an easier way to accomplish tasks via dialog-guides. It provides functions that XY does not have, it fills a gap. I am sure many more users down the road will thank you for this tool.

Maybe you could package the documentation above with the zip-file? It contains useful information about cache files in general and helps to understand what's going on under the hood. The program itself is pleasantly self-explanatory, from descriptive sub-menus to dialogs to reports. Well done!

There is nothing else I could wish for. You have made generating and maintaining thumbnails better manageable than in any other program I know of. Seriously, I really mean it. Build, delete, refresh - all of it geared towards specific db-files or folder locations - your options offer more control than the cache management of XnView and even better than Adobe's Bridge and Lightroom (judging from interface access only)

An outstanding tool, extremely valuable and useful. :beer: :beer:
Many many thanks over.
Stef

klownboy
Posts: 4141
Joined: 28 Feb 2012 19:27

Re: Script: Thumbnail Maintenance

Post by klownboy »

Thanks Stef123, it's good to know you (and hopefully others) will get some use out of it. Being a non-programmer in background, it doesn't come easy though better than a couple of years ago. Good idea on including a text help file. Some of the menu options aren't so self explanatory since they're very similar in what they do.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440

Post Reply