Well, after your advice, highend, I tweaked one of your own scripts for use in a custom column with button. It works
very well there. I use it when selecting a list of folders if I need to check contents first. And if I decide I really need to hop into one, it's certainly efficient. Thanks for your hard work - and the advice I required to tweak it
To use, put it in a custom column, similar to his picture above, only select folders instead of files, and select icon on top.
Code: Select all
/*
******************************************************************************
@SriptName: PreviewFolder.xys
@Author: Highend
@Created on: 2014-10-17 11:58:49
@Last modified: 2014-10-18 18:49:48
@Function: Preview the content of a selected folder
@Current version: v0.4
******************************************************************************
*/
$stepIntoFolders = 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);
// Only add entries if files or folders really 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 1=1;$lb$q-$q$lb$folders$lb$files";
} else {
$menuEntries = "$q$stats|:tsf$q end 1=1;$lb$q No entries...$q";
}
// Write the tmp script file and load it
writefile($tmpScriptFile, $menuEntries);
load $tmpScriptFile;
// Clean up
delete 0, 0, $tmpScriptFile;
} else {
status "No folder selected, aborted...", "CD6600", "stop"; // Dark orange
}
/*
******************************************************************************
@Changelog:
v0.4a
Tweaked for custom column button by Dustydog - after advice from highend, heh.
• Switched all <curitem> to <cc_item> so button press all that required rather than selection.
• Made stepIntoFolders default: Just because I like it, and because it makes
the feature more obvious.
• To get out of the preview, I've found that either ESC or clicking on the summary at
the top of the graphic to be best. Neither accidentally deselects or toggles anything.
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
******************************************************************************
*/
The only possible tweak beyond this for custom column purposes, would be to make it show on button press then disappear on lift - like a preview. But I doubt it's possible. Already, it activates on button release. Great, great script, highend.
(Ofc, resize the column with the button to only button size. Then save it in a column layout. His script can really help on folders with lots of items, especially if you've got a lot of columns or you have size active.)