Script: Thumbnail Maintenance

Discuss and share scripts and script files...
Stef123

Re: Script: Thumbnail Maintenance

Post by Stef123 »

Thanks Ken,
good idea to flag all relevant entries with the big flat dot. I noticed it picks just the first one - although I didn't even have thumbs for that, but since it was the same size ....
Anyway, it didn't seem important enough to mention it. BTW, my feedback concerns foreground tasks only, for some weird reason I was not able to run second instances. Must have been company-restrictions, low resources or whatever. Caused crashes and sometimes the script just ran ahead in the foreground anyway.
klownboy wrote:Concerning the Delete and Rebuild menu item, the whole idea on the at one was to strip out all the other caches other than the "one" you really want to keep. So right now anyway I'm thinking I'd rather keep it that way and if you need to rebuild multiple size use the other options.
Yep, using the other option did occur to me, of course. Besides, you explicitly caution the user what he is about to lose. And yet a few days later, I picked it again by accident or out of habit, on a deeply nested folder that processed for an hour or so. No big deal, I just wondered if those checkboxes could be used in Del&Rebuild as well.
klownboy wrote:I think XY is still doing something there that is holding some strays from being deleted. (i.e., still in memory). I remember discussing this with Don on another thread. I think sometimes it's probably better to do an exit and restart before using that option. I've never had a problem on a restart of XY. Maybe I should build a restart into that menu option though it would have to prompt the user.
Or just some info what he can do about it. It might even suffice to leave the folder and browse to a non-picture location. This seemed to work in some instance, if I remember correctly.
klownboy wrote:It will incorporate a change that Sammay requested where the current view will be pre-checked on some options.
I also like that suggestion.
Residue cleanup is great, too. It worked wonders on some folders. :tup:

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Hi, well I've been testing this next version 1.16 for a week now fixing issues as they popped up. Enough testing...here goes. The update includes:
- In the Rebuild Thumbnails and Delete and Rebuild menu options, the inputselect dialog box will pre-check the current view if and only if the current view is a tile or thumbnail view. Before it only informed you of the current view. Though it still does that as well regardless if it's tile or thumbnail view. Thanks Sammay for the requests - it's a nice addition.
- In the Delete and Rebuild menu options, the script will now allow the user to select more than one thumbnail/tile size to rebuild. Thanks Stef123 for the request - also a nice addition.
- Worked to eliminate (hopefully) a couple of error messages, one concerning the variable, $thumb_cid not being valid. The script now list all the potential views a user could be in not only the tile or thumbnail views in the replacelist. I haven't received it in the last week of testing. The other message concerns the cache still in memory. Not sure if we'll ever totally eliminate this one - too many variables, but I attempted to minimize it by using SC unthumb in a number of situations before attempting to delete the cache.
- In the inputselect dialog box, the script will now flag with the 'bel' symbol (the big fat dot), all thumbnail or tile size views that exist in the database. So for example, if you have a cache for the Small Tile size that is 128x128, and your Thumbnail #1 size is also that 128x128, then as a result, the Details with Thumbnails #1, Thumbnails #1 and Small Tile sizes will all be flagged. It makes sense since those 3 views would share the same cache.
Again please let me know if you experience any issues.
Thanks,
Ken
Edit: Updated the Zip file to resolve an issue concerning the paperfolder check discussed in the post below.
ThumbnailMaintenance_v1.16.zip
(323.09 KiB) Downloaded 276 times
Last edited by klownboy on 07 Feb 2015 23:35, edited 1 time in total.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Stef123

Re: Script: Thumbnail Maintenance

Post by Stef123 »

Thanks Ken,
for raising the comfort level yet another notch. I especially appreciate the multi-select in Delete & Rebuild. Quite a time saver with large and nested folders. These take time to generate, so I usually let it runs its course unattended. When coming back I no longer need to follow up with a second round of Build Thumbs. :D :appl:

I use it a lot on other machines, after directing XY to the local cache that I left there. As a quick and sure-fire approach to get the real status quo, including changes that the refresh-option may or may not capture. Very convenient that you allow the targeting of selected branches only.

Will keep an eye on the $thumb_cid error should it really come up again.

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

Re: Script: Thumbnail Maintenance

Post by bdeshi »

klownboy wrote: - In the Rebuild Thumbnails and Delete and Rebuild menu options, the inputselect dialog box will pre-check the current view if and only if the current view is a tile or thumbnail view. Before it only informed you of the current view. Though it still does that as well regardless if it's tile or thumbnail view. Thanks Sammay for the requests - it's a nice addition.
:tup: :appl: :appl:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Thanks Stef123 and Sammay. I just stumbled across a bug which came into play not on the last version 1.16, but the previous version 1.15, when I added a "paperfolder" check. My check for a paper folder consisted of:

Code: Select all

if((gettokenindex("paper", $path, ":")) {
Unfortunately since it was only written as a positive check, when you use a Build Thumbnail option on a folder like, "D:\Wallpaper\1920x1080\" it will provide a true response since it sees "paper" after the ":" colon and the result is "2". Obviously not what I wanted. The fix is easy. Change the line above to...

Code: Select all

if(gettokenindex("paper", $path, ":") == "1") { 
Which will give a "1" result only if "paper" is before the ":" which should only happen in a paper folder. I could have used SC gettoken as well.

If you've downloaded 1.15 or 1.16 already you can simply make the above change on line #674. It's 6 lines from the end. I will also update have updated the uploaded 1.16 version.
Thanks,
Ken
Last edited by bdeshi on 08 Feb 2015 15:11, edited 2 times in total.
Reason: :) [... have updated...]
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Script: Thumbnail Maintenance

Post by Filehero »

Ken,

phantastic script! :D

Cheers,
Filehero

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Thanks Filehero, it was your LayoutManager that got me interested in scripting. :)
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Script: Thumbnail Maintenance

Post by Filehero »

klownboy wrote:Thanks Filehero, it was your LayoutManager that got me interested in scripting. :)
:D :D Without YOUR constant support I would have never got that finished. :D :D

Anyway, just right now it's helping me a lot during nailing down some troubles.


Cheers,
Filehero

Stef123

Re: Script: Thumbnail Maintenance

Post by Stef123 »

Filehero wrote:Anyway, just right now it's helping me a lot during nailing down some troubles.
Same here, the script works heavy duty when you work on different screen resolutions that call for different thumb sizes. Black stripes and a myriad of other niggles - Ken has repeatedly saved my butt at numerous occasions. Pruning a branch is a lot smarter than cutting down the whole tree and growing the whole cache from ground zero, which can take a looooooong time.

spooky
Posts: 4
Joined: 28 Mar 2015 22:51

Re: Script: Thumbnail Maintenance

Post by spooky »

Hello!

I've just had a look at this script and like the idea of it a lot but there's a few things I can't get my head around, maybe it's just lack of sleep, if so I apologise up front.

Firstly is there a reason for setting the total path name to be read using readfile() to 75 bytes?
I have some files and folders whose total path name exceeds that limit and this script flags them up as invalid and suggests deleting them from the cache.
I changed the number of bytes to 255 to support long file names and it seems to work fine now.

Secondly, what really is the difference between the different cleaning methods?
Perhaps a brief description at the start of this thread or maybe a readme in the archive would be useful for people like me who are new to this script.

I haven't tried your script with cached search results yet, I stopped using that feature for some reason (I think the cache size got way out of hand), but does it handle them ok?

Regardless of the above, I'd just like to say thanks for the effort all those involved have put into making this script, it sure beats doing a total cache delete!

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Hey Spooky, thanks for the comments.
1. No, there no reason that I chose 75 in reading the dbits cache files. In looking at the hex view of the files there appears to be significant padding for the combination of file name and thumbnail size. It looks like you'd be fine in using 255. I'll up the script on the next revision to support longer file names.
2. The key difference is, some options use the existing cache file database and others use the current folder or current folder and subs. Of course there are also the options for performing the rebuilds or cleaning in the background or a second instance of XY. A couple of the current folder and current folder and sub options will provide a report of the change in database cache size (before / after). I explained most options as they were added to the original script. For example, look at this post http://www.xyplorer.com/xyfc/viewtopic. ... 15#p109742. At some point I'll update the first post to more clearly explain the options so people don't have to skim through the entire thread to figure it out.

There were some strange things going on when Don made changes a while back regarding the cache files, especially if you had caching turned off, which could result in the possibility of having stray dbits files with no associated dat2 file and maybe even the other way around. One option takes care of that possibility and also will update the caches in the backup if you use backup. The backup does not get rid of old caches when it adds or updates new ones so it can become larger than it should be or needs to be.

3. Honestly, I've never saved cached search results (I have it turned off /unchecked in configuration). It's just something I don't need or want personally. I assume the results in the cache would have to be stored in the same format (i.e., folder name and thumbnail size), but beyond that I'd have to do some research. Presently the options will check if a folder still exist or if it exist but has no files in it and let you know, but what happens with search results that are spread across folders, I don't know.

I hope you get some use out of the script. Thanks again,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Script: Thumbnail Maintenance

Post by Filehero »

Filehero wrote:phantastic script! :D
Still! :tup:

Ken, I don't know wether this is by-design or just over here, but:
the foreground jobs - Build Thumbnail Cache[current folder and cache], at least - only generate thumbs if XY's option Show Cached Thumbnails Only is unticked. If not, the script rather acts as a simulation (which is a huge fun and contemplating experience just like watching disk defragmentation in the Windows past. :mrgreen:), traversing through the tree without doing anything visible.

Is it only me?
If no, could XY's Show Cached Thumbnails Only maybe ignored when running the script?


Thanks,
FH

/e: corrected a wrong term
PS: soon, I'll be away for a couple of days and web might be inaccessible. So a reply of mine could take a while.
Last edited by Filehero on 31 Aug 2015 06:27, edited 1 time in total.

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

Filehero wrote: Delete & Rebuild Thumbnail Cache[current folder and cache], at least - only generate thumbs if XY's option Show Cached Thumbnails Only is unticked. If not, the script rather acts as a simulation (which is a huge fun and contemplating experience just like watching disk defragmentation in the Windows past. ), traversing through the tree without doing anything visible.
Actually though I haven't yet tried it, it doesn't surprise me. I haven't done any updates (that I remember) since those new options came into play. I typically have that option unticked so I suppose I wouldn't have seen that behavior.

I'll check it out as soon as I get a chance. Yes, I think you are right, I'd have to change that setting before accomplishing the rebuild. I suppose I'd have to inform users of that beforehand. Unfortunately there isn't a Command ID for "Show Cached Thumbnails Only" which means I'd have to change the setting with setkey and followed with a restart without saving. Maybe I'd be better of simply telling users in a post that you need that setting unticked. Do you know if you run it like you said with the option ticked and then untick it, will the script have rebuilt all the thumbnails and not just ones for those that previously existed? If I remember correctly the script uses #501 to regenerate the thumbs for a folder. Maybe it's a bug. Wouldn't you think that Command ID #501 should work regardless of that setting (i.e., all the thumbs should be rebuilt even though the setting is ticked/on - in my view point, the setting should be just a visual thing not controlling what #501 does)? That's why I asked, even though you can't see it, I wonder if the rebuild is taking place and you have to tick it to notice. Thanks Filehero, have fun at Berchtesgaden.

Edit: I forgot you said you were using "Delete and Rebuild" option. I still think my questions apply and all the thumbs should be rebuilt, but maybe it needs to be refreshed after the rebuild. Since the option is ticked possibly XY doesn't know they are rebuilt so another refresh is necessary. :whistle:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Script: Thumbnail Maintenance

Post by Filehero »

Hi Ken,

first of all, no hurry. It's a minor thing.

I have corrected my previous post, because it was the Build Cache option without Delete. Sorry for confusion.
klownboy wrote:Do you know if you run it like you said with the option ticked and then untick it, will the script have rebuilt all the thumbnails and not just ones for those that previously existed?
I ran it with the option ticked first (and all thumbs and meta information deleted before). There was not even an empty file generated in my XY thumbs folder.
klownboy wrote: Unfortunately there isn't a Command ID for "Show Cached Thumbnails Only" which means I'd have to change the setting with setkey and followed with a restart without saving. Maybe I'd be better of simply telling users in a post that you need that setting unticked.
I would go with such a simple user message. The focus should just be on avoiding surprises.

Thanks for your help.

Now away. :D

FH

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

Re: Script: Thumbnail Maintenance

Post by klownboy »

I've done some memory refreshing and background research mostly from http://www.xyplorer.com/xyfc/viewtopic. ... ly#p125537 and there definitely will be issues on any of the ThumbnailMaintenance options which use Refresh Thumbnails, CID #501, if the user has "Show only Cached thumbnails" ON. I typically do not have it on so I hadn't encounter the issue Filehero explained above. I ran some tests though and it is definitely a problem. There's no clean way to resolve it. I pondered the possibility of using "Create missing thumbnails", Command ID #507, if the script detected the setting "Show Only Cached Thumbnails" is ON, but that does not have the same desired cleanup affect that using Command ID #501 does and afterall that is what we are after in a script like this.

So based on the above I'll add a detection for "Show Only Cached Thumbnails" setting being ON, (if (getkey("CacheReadOnly", "Thumbs") == "1") { and provide a message that states to turn it off if you plan on rebuilding or refreshing thumbnails caches. It's not a problem if you're using options which delete caches.
Thanks Filehero,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply