Script: Thumbnail Maintenance

Discuss and share scripts and script files...
kileytoo
Posts: 53
Joined: 30 May 2012 22:10

Re: Script: Thumbnail Maintenance

Post by kileytoo »

Just downloaded and began to use version 1.18, thank you so much for sharing it.
I am using this on a portable install of XYplorer with the thumbnail cache in the same media.
I haven't found out yet if there is a recommended way to run the script (any usage examples?) but I think I am going to try and create a toolbar button for it.
Still looking into the commands list... this is what I understand so far:

Thumbnail Cache Clean-up [by folder using cache DB] = Clean up all folders/whole database
Refresh Thumbnail Cache [by folder using cache DB] = Refresh all folders
Thumbnail Cache Clean-up [current folder & subs] = Clean up current folder and subfolders

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Unfortunately some of the better explanations for the individual menu items are buried in the thread. I think this post has the best information. viewtopic.php?f=7&t=12257&start=45#p110631Personnally I use the second menu item most which simply refreshes or rebuilds the cache of existing image folders.
Windows 11, 22H2 Build 22621.1555 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 »

:ninja: hi, converted the descriptions to a list. JSYK.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

kileytoo
Posts: 53
Joined: 30 May 2012 22:10

Re: Script: Thumbnail Maintenance

Post by kileytoo »

I am having an issue with the option to build the thumbnail cache for the current folder and subfolders. Thumbs are created twice for each subfolder, except the first, which slows things down. Did anyone had the same issue, or know what may be causing it?

kileytoo
Posts: 53
Joined: 30 May 2012 22:10

Re: Script: Thumbnail Maintenance

Post by kileytoo »

I figured it out, it's because I have "create all thumbnails at once" checked. If I uncheck it, thumbs are still created twice, once by XYplorer normal behavior and once by the script, but since XYplorer only creates the thumbs that are visible, the slowdown is acceptable. This happens because the script navigates through the folder tree, rather than creating the thumbs in the background, so XYplorer's normal thumbnail creation is triggered every time. Maybe this option should only be available as a background task?

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Yes, unfortunately you have to be in the folder to refresh or build the cache. The script became a nightmare trying to work around that for all situations since you have to navigate to the folder to build the cache. Are you in the view desired for your thumbnails? Does the cache for that particular folder exist already? Is the cache being built because you just navigated to the folder? Does the cache exist but it's not up-to-date? You could try the Delete & Rebuild menu option in background operations, but I think there's an issue with it now. I'll take look at the script...it's been too long.
It would be nice if there was a scripting command for refreshing thumbnails (along with the CID #501) where you could call out the folder and thumbnail size (like thumbnail #1) especially if it didn't have to navigate to the folder to accomplish the rebuild.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

kileytoo
Posts: 53
Joined: 30 May 2012 22:10

Re: Script: Thumbnail Maintenance

Post by kileytoo »

I see... My first attempt at a workaround was to set XYplorer to list view before to run the script, but that didn't help since the script switches to thumbnail view automatically. What helps, in addition to having "create all thumbs at once" off, is to resize the main window to a very small size before to run the script so that XYplorer only creates a few thumbs. You can still see the script progress in the status bar.
Still, this option is very useful to me and much faster/easier than having to manually navigate through each folder and wait for the thumbs to be created or updated. :D

jupe
Posts: 2749
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Script: Thumbnail Maintenance

Post by jupe »

Just a suggestion if you are interested, I think this should work but haven't tried it (I don't use this script), what you could do as a workaround is you could make it so when you use that command it launches another XY instance with a particular window size with the command line switch /win= and then that instance does its thing then closes, then the thumbnails should be available in your normal instance.

you can paste the following into the XY address bar for more information if you are interested:

Code: Select all

help "idh_commandlineswitches.htm";

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Hi jupe and kileytoo, actually performing thumbnail maintenance in a second instance of XYplorer is exactly what the menu items under "Background Thumbnail Maintenance" do. In hindsight, maybe I should have more of the maintenance options currently accomplished in the foreground done in the background instead. Hopefully I'll have time to take a look at updating the script in the coming weeks.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Version 1.19
- I can't believe it's been that long since version 1.18 - over a year and a half. My main goal for this revision was to streamline thumbnail rebuilding as much as possible and minimize redundant thumbnail refreshing / rebuilding. A secondary goal was to perform the majority of maintenance operations in the background.

- There are instances where it may appear that the refresh/rebuild is occurring twice unnecessarily. Just as in normal use, the script may build some thumbs upon entering a folder but that could be due to the addition of images. Even when that occurs, the cache may not be truly rebuilt unless CID #501 (Refresh Thumbnails) is called. That is the purpose of the script to completely rebuild the cache eliminating extraneous thumbs and minimizing the cache size (i.e., there could be images that were renamed or deleted or moved which would still be in the database unless CID #501 is executed). I could invoke CID #507 to create any missing thumbnails but that command does not completely rebuild the cache.

- Folder View Settings (FVS) enabled and view modes for Tab styles may also affect thumbnail refreshing (e.g., a FVS for one particular thumbsize yet you select to build a thumbnail cache in another size.) In most situations I temporarily disable FVS to minimize unwanted refreshing of thumbnails, but some redundant refreshing may happen whether we like it or not. The script will provide a message stating so. When some redundancy does occur it's not really big deal since most of these operations are now performed in the background a separate instance of XYplorer running in the tray. Keep in mind though, if you have an FVS in one thumb view and you create thumbs in another size, the script may prevent the building of thumbs in the saved FVS thumb size, but unless you change save your FVS to the newly created thumb size XY will continue to display or re-build the thumbs in your old size thumbs. I'm not going to take it upon myself to change a Folder View Setting.

- My preference is to perform thumbnail maintenance operations in the background. Use a normal left click of the menu item to do this. If you prefer to do maintenance in the foreground (no reason to) hold the control key while clicking on the menu item. Background operations applies to menu items between the 2 divider lines.

- The two refresh menu options will properly recognize and rebuild both the regular and Zoom to Fill thumbnails as applicable. Whereas the normal rebuild options will rebuild in Zoom to Fill only if you have that setting on in Configuration | Thumbnails.

- For those that use the right click on a menu item function using AHK discussed here URL viewtopic.php?f=7&t=18062 URL, I may write another version which will use right and left click to distinguish between foreground and background operations. If anyone is interested let me know.

- I hope you can get some use out of it and thanks for trying it.

Menu Option Descriptions:

"Refresh Thumbnail Cache...by folder using cache DB" - This menu item provides you with a listing 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.Some of these menu items that rely on the thumbnail cache database may take a few seconds to appear on your display. The script has to obtain quite a lot of information from the cache files. So how quickly the menu displays depends on the amount of images cache file in the thumbnail folder.

"Refresh Existing Cache...current folder && subs" - This menu item refreshes the thumbnail caches for the current folder and all its subs. 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.

"Build Thumbnail Cache...current folder && subs" -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 either write new thumbnail cache or write over ones (i.e., "dat2" and "dbit" files ) that already existed in the XY thumbnail folder.

"Build Thumbnail Cache...current folder only - Size Data" - 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 either write new thumbnail cache or write over ones (i.e., "dat2" and "dbit" files ) that already existed in the XY thumbnail folder. You 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.

"Build Thumbnail Cache...current folder && subs - Size Data" - 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 too will provide you a report of the before and after thumbnail database files size for each folder and in each thumbnail size.

"Delete && Rebuild Thumbnail Cache...current folder && subs" - This can be a handy option in that it will first delete all thumbnail caches for the current folder and its sub folders and then build the thumbnails in the size(s) of your choice in that directory structure. It accomplishes this with little interaction other than initially selecting the thumbnail size(s).

"Thumbnail Cache Clean-up [by folder using cache DB]" - I use this option quite a bit just to determine what I have for thumbnail caches (i.e., folders, thumb sizes, etc.). You can cancel out of the report listing if you just wanted to investigate and not actually delete caches. This option is based strictly 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.

"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).

"Update Thumbnail DB for Image Folder Relocation" - This menu item updates the thumbnail cache(s) to recognize moving an image folder when not accomplihed by XYplorer using SC thumbscacherename. XYplorer will update the thumbnail caches when a folder move is accomplished within XYplorer. This may come in handy if you're setting up a new computer or used another file manager like Windows Explorer to accomplish a folder move (e.g., in setting up a new laptop, you have used your XYplorer files from a desktop where the images are in "G:\photos" and they are in "D:\pictures" on a new laptop). This menu item will update the thumbnail caches to reflect the new folder location and all the sub folders without having to rebuild the entire cache.

"Delete Entire Thumbnail Cache" - Careful, as stated it deletes the entire thumbnail cache after a warning prompt.
ThumbnailMaintenance119.jpg
ThumbnailMaintenance119.jpg (40.77 KiB) Viewed 7017 times
ThumbnailMaintenance_v1.19.zip
(181.79 KiB) Downloaded 529 times
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

I noticed an error in the latest version (1.19) the other day when using thumbnail cache database option to rebuild thumbnails, "Refresh Thumbnail Cache...by folder using cache DB". It arises only if you had some existing caches for folders that no longer exist or any image folder which no longer contains images. That particular menu option sends you to the delete thumbnail caches where those old caches are pre-checked for deletion. After deleting the old non-existing caches the script is suppose to return you to the original menu option. Unfortunately, I had changed the name of the SUB and didn't update it in the menu option. Until I update the script again, simply change line 47 from:

Code: Select all

		sub 'THUMB_DB'; sub 'THUMB_REFRESH'; end 1;
to:

Code: Select all

		sub 'THUMB_DB'; sub 'BG_THUMB_REFRESH'; end 1;
Thanks.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

FKF5482
Posts: 76
Joined: 06 Apr 2019 04:21

Re: Script: Thumbnail Maintenance issue

Post by FKF5482 »

Hello everyone!

Is anyone getting this error code when he is trying to run the
"Refresh Thumbnail Cache...by folder using cache DB" or "Thumbnail Cache Clean-up [by folder using cache DB"?
I have no idea what it means. I've made all the changes klownboy suggested in his last post.

Image

Thanks in advance :)

jupe
Posts: 2749
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Script: Thumbnail Maintenance

Post by jupe »

Put quotes around the MB at the end of that line that is indicated, it should fix the error.

FKF5482
Posts: 76
Joined: 06 Apr 2019 04:21

Re: Script: Thumbnail Maintenance

Post by FKF5482 »

I've put quotes as you said and its working with no errors. Thank you for your help Jupe :)

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Thanks FKF5482 for pointing that out and thanks Jupe for correcting. :cup:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply