popupmenu - Add nested submenus
popupmenu - Add nested submenus
Hi Guys, first post here.
Thank you for the amazing forums and software.
I'm really new to scripting, as you'll see by my question.
I want a popupmenu that has a top level and then sub levels that get populated by the script iterating through a folder and returning all the subfolders as menus. Then within that sub menu is a copyto command using that same token.
I've tried hacking together copy pasted bits that I can find from the help menu and from here, but my knowledge of the syntax isn't enough.
I'm not sure how to use the popupmenu and foreach loops together.
Thanks in advance.
Thank you for the amazing forums and software.
I'm really new to scripting, as you'll see by my question.
I want a popupmenu that has a top level and then sub levels that get populated by the script iterating through a folder and returning all the subfolders as menus. Then within that sub menu is a copyto command using that same token.
I've tried hacking together copy pasted bits that I can find from the help menu and from here, but my knowledge of the syntax isn't enough.
I'm not sure how to use the popupmenu and foreach loops together.
Thanks in advance.
Re: Foreach into popupmenu
A while loop makes more sense here to check if an entry has submenus or not...
Code: Select all
$iconFolder = ":showfolders";
$iconCommand = ":copyto";
$selectedItems = <get SelectedItemsPathNames |>;
end (!$selectedItems), "No item(s) selected, aborted!";
$folders = quicksearch("/d /excl=$RECYCLE.BIN;System Volume Information", , , "s");
$folders = replace($folders, "<curpath>\");
$menu = "";
$indent = <space 4>;
$lastFolder = "";
while ($folders) {
$folder = gettoken($folders, 1, <crlf>);
$folders = gettoken($folders, 2, <crlf>, , 2);
$cntIndent = gettoken($folder, "count", "\") - 1;
if ($folder != $lastFolder) {
$indentation = strrepeat($indent, $cntIndent);
$caption = gpc($folder, "component", -1);
$menu .= <crlf> . $indentation . "$caption<:><:>$iconFolder";
}
if (strpos($folders, $folder) != 0) {
$indentation = strrepeat($indent, $cntIndent + 1);
$data = "copyto " . quote("<curpath>\$folder") . ", " . quote($selectedItems) . ", , 2, 2;";
$menu .= <crlf> . $indentation . "Copy <selected items> here...<:>$data<:>$iconCommand";
}
$lastFolder = $folder;
}
$selection = popupnested($menu, 6:=<crlf>, 7:="<:>");
if ($selection) { load $selection, , "s"; }
One of my scripts helped you out? Please donate via Paypal
Re: Foreach into popupmenu
Hey highend. You should change the title on this thread so others know what it actually does (e.g., Folder submenu operations or similar). Right now no one would have a clue unless they looked through the thread.
The OP hadn't yet responded so I figured I would. The script works nicely. It was easy enough to modify the script to add additional submenus for "Move to" along with the "Copy to" and a couple of fixed folder locations just to provide more flexibility.
The OP hadn't yet responded so I figured I would. The script works nicely. It was easy enough to modify the script to add additional submenus for "Move to" along with the "Copy to" and a couple of fixed folder locations just to provide more flexibility.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: popupmenu - Add nested submenus
Title changed
Actually he wasn't ever online again. This is more or less an existing user who was (as always) too lazy to achieve something on his own...The OP hadn't yet responded so
One of my scripts helped you out? Please donate via Paypal
Re: popupmenu - Add nested submenus
Haha, little harsh?who was (as always) too lazy to achieve something on his own...
I agree, I should have said thank you or given feedback a little earlier... but I definitely wasn't too lazy to achieve this on my own.
Truth is, I'm not one to ask to be spoonfed without trying to figure out things on my own first.
Thank you for your reply.
So I got as far as using your code and then getting stuck again and I haven't had time to ask for more help or look at it further.
The example you provided is almost what I need, but I would like it to only go "one level down."
So basically, I point the script to a parent folder, and it just lists the immediate sub folders, not further down than that.
I think I tried to use folder report instead of quicksearch because I couldn't figure out how to limit it to one child level.
Got it to list just the subfolders I wanted, but then got stuck at something else.
Will confirm and provide more info in the morning when it's in front of me.
Thanks for the title name change, better.
Re: popupmenu - Add nested submenus
If you only want to see the immediate subfolders (1 level), change the SC quicksearch line to read as follows:
That should do what you want.
$folders = quicksearch("/d /maxdepth=0 /excl=$RECYCLE.BIN;System Volume Information", , , "s");
That should do what you want.
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
Re: popupmenu - Add nested submenus
klownboy, thank you for your response!
Re: popupmenu - Add nested submenus
Can I please have a version of this which would list for target all folders from panes 1 (and 2, if it's dual pane) as well as a 3 options submenu as for copy, backup and move? Thanks.
Re: popupmenu - Add nested submenus
You mean the path of the existing tabs?for target all folders from panes 1 (and 2, if it's dual pane)
One of my scripts helped you out? Please donate via Paypal
Re: popupmenu - Add nested submenus
Tested! Works! Thanks!
Re: popupmenu - Add nested submenus
Can it be like this?
- Attachments
-
- Paste Here with Path.png (3.91 KiB) Viewed 2686 times
Re: popupmenu - Add nested submenus
Thank you. I saw the flags and looked up the help file.
$data = $root. " " . quote($tmpFolder) . ", " . quote($selectedItems) . ",0 , 2, 2;";
$data = $root. " " . quote($tmpFolder) . ", " . quote($selectedItems) . ",0 , 2, 2;";