Page 1 of 1
How to expand a tree folder to show direct subfolders only?
Posted: 12 Jun 2012 18:10
by Jerry
How can I have a script expand the currently selected folder in the Mini Tree to show just the direct subfolders under that folder and no further levels down? In other words, do the equivalent of clicking on the + control for the folder for the first time or after it's been hidden and put back into the Mini Tree.
I always use the Mini Tree and sometimes want to see all the direct subfolders under a parent folder instead of just the ones I've been visiting. So I started a script that does this, but can't find a way to do the final step.
Code: Select all
$path=tab("get", "path");
loadtree($path, 2); // first hide the parent folder
loadtree($path, 1); // then, add it back into the Mini Tree
// Next, how to expand $path to show just immediate subfolders only?
Jerry
Re: How to expand a tree folder to show direct subfolders on
Posted: 12 Jun 2012 18:18
by highend
Too tired to think and too lazy to code atm
But why don't you store a list of all current subfolders via folderreport() in a variable and load them through a foreach loop?
Re: How to expand a tree folder to show direct subfolders on
Posted: 12 Jun 2012 18:24
by Jerry
highend wrote:But why don't you store a list of all current subfolders via folderreport() in a variable and load them through a foreach loop?
That approach seems awfully complicated to do a very simple thing. I'd rather see Don add an
expand command with options to fully expand or only expand 1 level deep. In fact, I'm rather surprised there wasn't an existing command to do this already.
Jerry
Re: How to expand a tree folder to show direct subfolders on
Posted: 12 Jun 2012 19:12
by neutrox
this way:
Code: Select all
$startpath = "<curpath>";
$folders = get(selecteditemspathnames);
foreach($folder, $folders, "<crlf>") {
$sec = exists($folder);
if ($sec == 2) { }
elseif ($sec != 2) { continue 2; }
$subreport = folderreport("dirs", "r", "$folder", "");
if ($subreport == "") { }
elseif ($subreport != "") { goto gettoken($subreport, 1, "<crlf>"); }
}
Instructions:
-turn on minitree;
-select the target folders you want to see expanded or select all, the script will ignore FILES if selected;
-run the script.
I use this on regulartree and it happens to work on minitree.

Re: How to expand a tree folder to show direct subfolders on
Posted: 12 Jun 2012 19:34
by admin
FYI, hold CTRL when you collapse a mini tree node by clicking on the little "minus" and it will be initialized: Next time you click the little "plus" you will see all subfolders.
Re: How to expand a tree folder to show direct subfolders on
Posted: 12 Jun 2012 19:41
by Jerry
admin wrote:FYI, hold CTRL when you collapse a mini tree node by clicking on the little "minus" and it will be initialized: Next time you click the little "plus" you will see all subfolders.
Ok, that will be easier than scripting, in the absence of an expandtree command. Thanks.
Jerry
Re: How to expand a tree folder to show direct subfolders on
Posted: 12 Jun 2012 20:26
by Jerry
neutrox wrote:this way:
Code: Select all
$startpath = "<curpath>";
$folders = get(selecteditemspathnames);
foreach($folder, $folders, "<crlf>") {
$sec = exists($folder);
if ($sec == 2) { }
elseif ($sec != 2) { continue 2; }
$subreport = folderreport("dirs", "r", "$folder", "");
if ($subreport == "") { }
elseif ($subreport != "") { goto gettoken($subreport, 1, "<crlf>"); }
}
Thanks neutrox. I'll keep this script in mind for future needs. But as Don suggested, holding down Ctrl and pressing the little minus, followed by the little plus without Ctrl, is the answer for this particular problem, for me at least.
Jerry
Re: How to expand a tree folder to show direct subfolders on
Posted: 10 Jul 2015 18:33
by hermhart
Could an option under "Expansion" be added into the popup context menu you get when you right-click on a folder in the tree:
Fully Expand
Expand by level... (new option - opens a dialogue to ask how many levels deep to expand?)
Fully Collapse
-
Fully Collapse Drive
Optimize Tree
Re: How to expand a tree folder to show direct subfolders on
Posted: 26 Jul 2015 18:19
by admin
In theory yes, but overkill ATM.
Re: How to expand a tree folder to show direct subfolders on
Posted: 27 Jul 2015 19:09
by Papoulka
I keep trying to use Minitree but run into the same problem with not easily viewing first-level folders. Even with the Ctrl key I could never get it right.
Now I wonder if there is a bug here. Starting with a ::fresh instance, I enable Minitree and navigate to a main folder which has 50 direct folders (each with one subfolder). Then holding Ctrl down the whole time, in the Tree pane I repeatedly left-click the '+/-' symbol for this main folder. With each click the Tree pane changes, which is fine. However, it sometimes shows the 50 direct folders only, and other times shows the 50 direct folders and their subfolders i.e. expanded. Sometimes it shows the expanded view for several clicks, then after a few (or even 10) clicks switches back to direct folders only.
I thought at first that it is supposed to cycle through some sequence of presentations, but I don't see a pattern.
This is with XY v15.40.0102.