Page 1 of 3

PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 13:18
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 5012 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 376 times
Old version(s):
PreviewFolder_v0.6.3.xys
(7.03 KiB) Downloaded 238 times
PreviewFolder_v0.6.2.xys
(6.91 KiB) Downloaded 213 times
PreviewFolder_v0.6.1.xys
(6.22 KiB) Downloaded 288 times
PreviewFolder_v0.6.xys
(5.66 KiB) Downloaded 239 times
Old version download count: 365

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 15:42
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?

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 16:15
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.

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 16:38
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.

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 16:43
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

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 17:45
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...

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 18:52
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

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 19:08
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*

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 17 Oct 2014 21:59
by klownboy
No you're not missing anything. Sorry and excuse me, I must have been having an old age moment. :beer:

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 18 Oct 2014 09:36
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?

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 18 Oct 2014 10:25
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

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 18 Oct 2014 14:00
by Stef123
Very nice. Thanks. :beer:
One more thing came up: Files and folders staring with an underscore_ don't get listed. :wink:

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 18 Oct 2014 15:25
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...

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 18 Oct 2014 16:31
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.

Re: PreviewFolder - Get a peek preview for folder contents

Posted: 18 Oct 2014 18:52
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.