PreviewFolder - Get a peek preview for folder contents

Discuss and share scripts and script files...
highend
Posts: 13274
Joined: 06 Feb 2011 00:33

PreviewFolder - Get a peek preview for folder contents

Post by highend »

Probably the best way to handle it is to assign this script a keyboard shortcut (although it does work on a CTB as well)...

What it does?

You select a folder and hit the shortcut that you've assigned to this script and you get:
screenshot.png
screenshot.png (9.41 KiB) Viewed 4961 times
Depending on the $mode variable's content you step into the parent folder of the clicked item
and select the item ($mode = 0), jump directly in a clicked folder ($mode = 1) or move the
clicked item into the selected folder in the inactive pane (or when no folder is selected,
in the current path of the inactive pane) ($mode = 2).

The current mode is displayed in the stats line at the top of the menu (Select, Go into, Move)...

Pros:
Works without any additional tools
Shows icons flawlessly

Current version:
PreviewFolder_v0.6.4.xys
(7.5 KiB) Downloaded 374 times
Old version(s):
PreviewFolder_v0.6.3.xys
(7.03 KiB) Downloaded 236 times
PreviewFolder_v0.6.2.xys
(6.91 KiB) Downloaded 212 times
PreviewFolder_v0.6.1.xys
(6.22 KiB) Downloaded 285 times
PreviewFolder_v0.6.xys
(5.66 KiB) Downloaded 236 times
Old version download count: 365
One of my scripts helped you out? Please donate via Paypal

Stef123

Re: PreviewFolder - Get a peek preview for folder contents

Post by Stef123 »

With large folders it takes a really long time to process, naturally.
The problem is I cannot cancel the script in such instances when nothing seems to happen for a while. I either have to kill XY or wait :whistle:

EDIT:
Is there a (scripting) way to automatically execute #1062 upon selection change, if the focused item is a folder?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend »

The question is, which part of it takes so long?

The listfolder / foldersize commands?

Adding the icons for each entry?

Writing the temp file?

Let's start with listfolder / foldersize:

Code: Select all

    $loops = 5;

    $i = 0;
    $execTimeLF = 0;
    $execTimeFS = 0;
    while ($i < $loops) {
        $startLF = now("msecs");
        $items = listfolder("<curpath>", , 4, $lb);
        $durationLF = now("msecs") - $startLF;
        $execTimeLF = $execTimeLF + $durationLF;

        $startFS = now("msecs");
        $items = listfolder("<curpath>", , 4, $lb);
        $durationFS = now("msecs") - $startFS;
        $execTimeFS = $execTimeFS + $durationFS;
        $i++;
    }
    $listfolder = "Processed: Listfolder<crlf>Loops: $loops<crlf>Exectime: $execTimeLF msecs";
    $folderSize = "Processed: Foldersize<crlf>Loops: $loops<crlf>Exectime: $execTimeFS msecs";

    text "$listfolder<crlf 3>$folderSize";
Create a .xys file in that folder that takes so long, paste this script into it and execute it afterwards.
If you get execution times < 1000 (msecs), raise the loop value!

Post results...
EDIT:
Is there a (scripting) way to automatically execute #1062 upon selection change, if the focused item is a folder?
There is no way to do anything scripting wise from inside XY when anything like that happens.
One of my scripts helped you out? Please donate via Paypal

Stef123

Re: PreviewFolder - Get a peek preview for folder contents

Post by Stef123 »

Exectime: 514 msecs - no problem so far.

Thanks for the answer to focus-change. A pity that XY cannot be made to act on it. :( I was already getting all revved up on my plans to preview folder content without additional trigger keys.

Stef123

Re: PreviewFolder - Get a peek preview for folder contents

Post by Stef123 »

Another thing I noticed: The sluggishness it not linear. When you preview, say, Windows System32 with roughly 4000 files in it, it takes around 20secs, an old photoshop archive with 8000 files doesn't take twice as long but almost a minute. Not sure if the content itself makes a difference.
No time for further testing, something else came up

Later....
Stef

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend »

Shouldn't matter...

New version up, should be between 10 and a 100 times faster than v0.1...

foreach loops are evil, regexmatches / regexreplace rules...
One of my scripts helped you out? Please donate via Paypal

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by klownboy »

If( highend and Regex == "1") { :appl: } Yeah I know bad syntax.

Why not make the script work on <curpath> when the folder is not selected in the list pane. So if I have a folder in the tree selected or focused, it will use that that a folder. After all, it is a folder peak script so you'd kind of expect it to work on a folder selected via the tree if the user doesn't have a folder selected in the list pane.

Code: Select all

if(("<curitem>" != "") AND (exists("<curitem>") != "1")) {$cur_folder = "<curitem>";} else {$cur_folder = "<curpath>";}
Thanks,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend »

I don't understand...

Regardless of which folder you select in the tree, it's content is displayed in the list pane, right?

Why should I display a preview of the folder I'm currently in? There must be something that I'm missing... *shrug*
One of my scripts helped you out? Please donate via Paypal

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by klownboy »

No you're not missing anything. Sorry and excuse me, I must have been having an old age moment. :beer:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Stef123

Re: PreviewFolder - Get a peek preview for folder contents

Post by Stef123 »

You solved the delay problem, now it's fast enough to be used on large folders as well. :D
What I liked better before was the immediate access to subfolders, simply by clicking on them. Whereas the new version only highlights the subfolder. Any chance to customize that behavior?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend »

Any chance to customize that behavior?
v0.3 has the variable: $stepIntoFolders = 0;

0 = only select the folder
1 = step into it instead
One of my scripts helped you out? Please donate via Paypal

Stef123

Re: PreviewFolder - Get a peek preview for folder contents

Post by Stef123 »

Very nice. Thanks. :beer:
One more thing came up: Files and folders staring with an underscore_ don't get listed. :wink:

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend »

Yeah, that's because the underscore as the first char for a subscript stands for a hidden one.

I have a solution in place but I don't know if it'll work on every system...

If you want to try it, do the following:

Code: Select all

        // Only add entries if there really are files or folders!
        if ($files) {
            $files   = regexreplace($files, "^(.*?$)(\r?\n|$)", "$q$1|<curitem>\$1$q goto $q<curitem>\$1$q;$lb");
        }
Replace that part with this one:

Code: Select all

        // Only add entries if there really are files or folders!
        if ($files) {
            $files = regexreplace($files, "^(.*?$)(\r?\n|$)", "$q$1|<curitem>\$1$q goto $q<curitem>\$1$q;$lb");
            // Replace an underscore (otherwise it would be a hidden script)
            $files = regexreplace($files, "^(.)_", "$1" . chr(31) . "__");
        }
Does that still work, is the file still shown with just a single leading underscore?

Ofc I know that this is necessary for folders as well...
One of my scripts helped you out? Please donate via Paypal

Stef123

Re: PreviewFolder - Get a peek preview for folder contents

Post by Stef123 »

Yep, that did the trick. At least for the machine under my fingers right now. Do you mean to say it might not work for other operating systems? Or for other directory environments?
Could you do the same for folders?
highend wrote:that's because the underscore as the first char for a subscript stands for a hidden one.
I remember reading about it, somewhere in a XY beginners' tutorial. A very unfortunate choice of char if it causes interference with files and folders. The underscore is a common prefix imo, to make files float up to the top for quick access.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend »

It would be more of a font issue. Don't know if all fonts on all Windows version (& languages) have the exact same set of ascii chars. Ofc they should but I didn't test that...

v0.4 is online, it should fix the underscore "issue" for all files & folders.
One of my scripts helped you out? Please donate via Paypal

Post Reply