PreviewFolder - Get a peek preview for folder contents

Discuss and share scripts and script files...
Stef123

Re: PreviewFolder - Get a peek preview for folder contents

Post by Stef123 » 18 Oct 2014 20:12

v0.4 seems flawless :appl:
highend wrote: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...
So it's not really much to worry about. Sounds like chances are high it'll work everywhere. 8)

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 19 Oct 2014 13:34

What about displaying $RECYCLE.BIN | System Volume Information folders?

What about files / folders that have the hidden attribute?
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 17 Apr 2017 09:19

v0.5 published

Just a minor change:
v0.5
• Changed: Filtering system folders is now an option ($filterSystemFolders)
The stats at the top of the menu are correct accordingly when
this option is turned on

• Note: If you want to use the script in a custom column, just replace
all occurrences of <curitem> with <cc_item>
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Dustydog
Posts: 263
Joined: 13 Jun 2016 04:19

Re: PreviewFolder - Get a peek preview for folder contents

Post by Dustydog » 22 Apr 2017 06:09

This is what I've been doing with this lately. It's edited to work from a column, as you mention, plus it will launch MediaInfo (just made a couple of one-liners, easy to comment out) when run on either a file or when jumped to a file. Thanks for an extremely useful script, highend.

Code: Select all

/*
******************************************************************************
@ScriptName: PreviewFolder.xys
@Author: Highend
@Created on: 2014-10-17 11:58:49
@Last modified: 2017-04-17 09:16:22
@Function: Preview the content of a selected folder
@Current version: v0.5
******************************************************************************
Lightly edited for use in a Custom Column with Button, jump active by default,
  and for use with installed GUI MediaInfo (hard path).
******************************************************************************
*/

    // 0 = Don't go into the clicked folder, but into it's parent and select it
    // 1 = Really go into the clicked folder
    $stepIntoFolders = 1;

    // Remove $RECYCLE.BIN & System Volume Information folders from the list
    $filterSystemFolders = 1;

    $tmpScriptFile = "%TEMP%\~" . self("base") . ".xys";

    $q = chr(34);
    $lb = <crlf>;

    // If the selected item is really a folder
    if (exists("<cc_item>") == 2) {
        // Get content and stats
        $stats   = foldersize(<cc_item>, "Stats: <d> folder(s), <f> file(s)", 0);
        $files   = listfolder(<cc_item>, , 1+4, $lb);
        $folders = listfolder(<cc_item>, , 2+4, $lb);

        if ($filterSystemFolders) {
            // Stats: 13 folder(s), 1 file(s)
            $countBefore = gettoken(regexmatches($stats, "\d+"), 1, "|");
            $folders     = formatlist($folders, "ef", $lb, "!$RECYCLE.BIN<crlf>System Volume Information");
            $countAfter  = gettoken($folders, "count", $lb);
            $difference  = $countBefore - $countAfter;
            if ($countBefore != $countAfter) { $stats = regexreplace($stats, "\d+ folder\(s\)", "$countAfter folder(s) [$difference hidden]"); }
        }

        // Only add entries if files or folders exist!
        if ($files) {
            $files = regexreplace($files, "^(.*?$)(\r?\n|$)", "$q$1|<cc_item>\$1$q goto $q<cc_item>\$1$q;$lb");
            $files = regexreplace($files, "^(.)_", "$1" . chr(31) . "__"); // Replace a leading underscore
        }

        if ($folders) {
            if ($stepIntoFolders) {
                $folders = regexreplace($folders, "^(.*?$)(\r?\n|$)", "$q$1|<cc_item>\$1$q goto $q<cc_item>\$1$q;$lb");
            } else {
                $folders = regexreplace($folders, "^(.*?$)(\r?\n|$)", "$q$1|<cc_item>\$1$q goto $q<cc_item>$q; selectitems $q$1$q;$lb");
            }
            $folders = regexreplace($folders, "^(.)_", "$1" . chr(31) . "__"); // Replace a leading underscore
        }

        // Different menus for empty or not empty folders
        if (regexmatches($stats, "[1-9]")) { // At least one file or folder is present
            $menuEntries = "$q$stats|:tsf$q end true;$lb$q-$q$lb$folders$lb$files";
        } else {
            $menuEntries = "$q$stats|:tsf$q end true;$lb$q No entries...$q";
        }

        // Write the tmp script file and load it
        writefile($tmpScriptFile, $menuEntries);
        load $tmpScriptFile;

        // Clean up
        delete 0, 0, $tmpScriptFile;
        If (exists("<curitem>") == 1) {run "C:\Program Files\MediaInfo\MediaInfo.exe" "<curitem>"}; // If a file ends up selected from jumping to it, then run MediaInfo on it. Can comment out. <-Leave these as curitem.
    } else {
        If (exists("<cc_item>") == 1) {run "C:\Program Files\MediaInfo\MediaInfo.exe" "<cc_item>"}; // If the main script didn't apply to a folder, run MediaInfo on a file. Can comment out.
//        status "No folder selected, aborted...", "CD6600", "stop"; // Dark orange Can uncomment.
    }

/*
******************************************************************************
@Changelog:
v0.5
 • Changed: Filtering system folders is now an option ($filterSystemFolders)
            The stats at the top of the menu are correct accordingly when
            this option is turned on

 • Note: If you want to use the script in a custom column, just replace
         all occurrences of <curitem> with <cc_item>

v0.4
 • Fixed: Display of files / folders with a leading underscore

v0.3
 • Fixed: Only add files / folders to the menu if there are any (bug)
 • Added: Option to just select or step into folders

v0.2
 • Changed: Foreach loop with regexreplace(s). Speed up by factor 10 and up

v0.1
 • COMMENT: Initial version

******************************************************************************
*/

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 15 May 2017 14:14

v0.6 published

Code: Select all

v0.6
 • Added: Value 2 for $stepIntoFolders. When an entry (file or folder) is
          clicked, that item is moved to the inactive pane's selected folder
          (or to the inative pane's path if no folder is selected in it).
          When the stats line is clicked, the complete folder is moved
          to the inactive pane (or it's selected folder)
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 16 May 2017 10:53

v0.6.1 published

Code: Select all

v0.6.1
 • Changed: Renamed $stepIntoFolders into $mode

 • Added: The stats line at the top will now show the mode in square
          brackets at the end

One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 19 Sep 2017 09:40

v0.6.2 published

Code: Select all

v0.6.2
 • Added: The position of the stats line is now configurable.
          $statsPosition is the option to configure.
          "t" = top
          "b" = bottom
          If it is left empty or a different character is used, "t"
          will be used automatically
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by SammaySarkar » 24 Sep 2017 11:40

[this is nitpicky.]
is there any demerits to inserting a `setting 'BackgroundFileOps', 0;` statement before the delete stmt (`delete 0,0 $tmpScriptFile`)? Keep getting "background operations completed" status on script completion.

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 24 Sep 2017 11:56

v0.6.3 - Minor change: Suppressing "background operations completed" message on cleanup...
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Anselma
Posts: 78
Joined: 17 Jan 2012 07:31

Re: PreviewFolder - Get a peek preview for folder contents

Post by Anselma » 04 Dec 2017 05:29

Does this script display overlay icon inside the previewed folder?

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 04 Dec 2017 09:04

No, XY does not get that kind of icon when presented via
popupmenu / popupnested / as script captions
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Dustydog
Posts: 263
Joined: 13 Jun 2016 04:19

Re: PreviewFolder - Get a peek preview for folder contents

Post by Dustydog » 06 Dec 2017 23:49

This is my all-time favorite shared script, highend, thank you again for your hard work. Your coding is admirably clear as well as being creative and useful in the first place. This script is something everyone really should be using. :appl:

Since I'm a mouser, I've always got this active in a custom column - which I find extremely convenient. The only line I added for that is:

if (!<curitem>) {selectitems "<cc_item>";}

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 07 Dec 2017 00:44

Posted an updated version

Code: Select all

v0.6.4
 • Fixed: The menu access modifier "&" in the caption is now replaced
          with "&&" to not show incorrect file / folder names

One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

suslo
Posts: 138
Joined: 02 Feb 2015 05:02

Re: PreviewFolder - Get a peek preview for folder contents

Post by suslo » 21 Apr 2018 10:34

please add the following features to this useful script:

1. (the current behaviour) when clicking on a file in the small preview window, the tree is auto-expanded to the corresponding folder and the file becomes selected in navigation panel

(the suggested new behaviour) when clicking on a file in the small preview window, nothing changes in the tree and the file becomes opened in a corresponding program (for example, txt-file - in notepad)
i ask to implement an option to choose between these 2 variants

2. an option to change the font/size (in the small preview window)
i wish that the content was easier to read in this window (a bigger font would be a relief)
now i have these font-settings in my navigation panel: tahoma, font style - regular, size - 12, script - western
and if possible, i would like to try the same in this small preview window


3. (in the small preview window) an option to hide all icons (the icon of stats, the icons of folders, the icons of files)

4. an option to show/hide the separator between folders and files

5. if there are too many items, they don't fit the vertical space and 2 small arrows are visible around the list of items
a) is it possible to add the support for scrolling?
b) is it possible to implement an option to choose between displaying those arrows and not displaying them?

6. (in the small preview window) when there are several lines that begin with the 's' letter:
the 'Stats:' line also becomes selected after pressing the 's' letter
this is the least important aspect among the others but i think it would be better if the 'Stats:' line was not selected when pressing the 's' letter

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

Re: PreviewFolder - Get a peek preview for folder contents

Post by highend » 21 Apr 2018 11:33

1. While possible, no intend to do this. It's not meant as a program starter / opener
2. Not possible
3. I see absolute no usage in this
4.
You can easily change that yourself

Code: Select all

$menuEntries = "$folders$lb$files";
becomes

Code: Select all

$menuEntries = "$folders$lb-$lb$files";
5a. Not without XYplorer adding it
5b. Not without limiting the number of displayed items (or putting them in subcategories: a-z, 0-9, other characters)
Limiting is not an option, it would render the whole script useless
6. You are free to put any character (that is not valid in a file name!), e.g. a ":" in front of the Stats part here:

Code: Select all

$stats   = foldersize(<curitem>, ":Stats: <d> folder(s), <f> file(s)", 0);
Maybe you're better off forking the whole script and implement e.g. 1, 3 and 5b yourself...
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

Post Reply