How to Show Folders within a Tree without Parents or Subfolders with a Regexp

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
highend
Posts: 9101
Joined: 06 Feb 2011 00:33

Re: How to Show Folders within a Tree without Parents or Subfolders with a Regexp

Post by highend » 15 Aug 2018 12:17

So you want to see only folders that contain files (but not the files itself)...

Code: Select all

    $path = <curpath>;
    $files = quicksearch("/f", $path);
    $folders = regexreplace($files, "[^\\]*?(?=\r?\n|$)");
    $folders = formatlist($folders, "de", <crlf>);
    paperfolder("Folders_with_Files", $folders);
You need to add the path column to the paperfolder view, so that displayed subfolders get their real context, though...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

pdupreez
Posts: 19
Joined: 15 Aug 2018 11:40

Re: How to Show Folders within a Tree without Parents or Subfolders with a Regexp

Post by pdupreez » 15 Aug 2018 12:49

highend wrote:So you want to see only folders that contain files (but not the files itself)...

Code: Select all

    $path = <curpath>;
    $files = quicksearch("/f", $path);
    $folders = regexreplace($files, "[^\\]*?(?=\r?\n|$)");
    $folders = formatlist($folders, "de", <crlf>);
    paperfolder("Folders_with_Files", $folders);
You need to add the path column to the paperfolder view, so that displayed subfolders get their real context, though...
Thanks, learned about PaperFolders too....
I ended up with this:

Code: Select all

    
    $path = "N:\RoughTagged\";
    $files = quicksearch("/f", $path);
    $folders = regexreplace($files, "[^\\]*?(?=\r?\n|$)");
    $folders = formatlist($folders, "de", <crlf>);
    paperfolder("FoldersWithoutSubfolders", $folders);
    
That however goes down to the nth level of all the folders in current path, and give me those folders as output, like such

Current:/Folder1/Sub 1/Sub 2/Files
Current:/Folder2/Sub 1/Sub 2/Files
Current:/Folder3/Files

and gives me in PaperFolder

Current:/Folder1/Sub 1/Sub 2/
Current:/Folder2/Sub 1/Sub 2/
Current:/Folder3/

instead of only

Current:/Folder3/

as per screenshot Image

jupe
Posts: 1285
Joined: 20 Oct 2017 21:14
Location: 2004 x64

Re: How to Show Folders within a Tree without Parents or Subfolders with a Regexp

Post by jupe » 15 Aug 2018 12:52

With your example above if you are positioned in this path, "Drive:/Current Dir/" and used this in the XY address bar:

Code: Select all

<curpath>?/md=1 /dx
it should do what you want too, if I am understanding correctly.

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

Re: How to Show Folders within a Tree without Parents or Subfolders with a Regexp

Post by highend » 15 Aug 2018 12:56

So why don't you say that in the first place, that the scan depth needs a limitation?

So you could also follow jupes advice and do it like this (because it seems you don't want to use <curpath> but a fixed one):

Code: Select all

goto "N:\RoughTagged\?/md=1 /dx";
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

pdupreez
Posts: 19
Joined: 15 Aug 2018 11:40

Re: How to Show Folders within a Tree without Parents or Subfolders with a Regexp

Post by pdupreez » 15 Aug 2018 12:59

jupe wrote:With your example above if you are positioned in this path, "Drive:/Current Dir/" and used this in the XY address bar:

Code: Select all

<curpath>?/md=1 /dx
it should do what you want too, if I am understanding correctly.
Wow, that is awesome. Found 547 folders in a flash.

Now if I only know what it means (My problem, I will go and read up). Thanks to you and highend

Thanks a lot

pdupreez
Posts: 19
Joined: 15 Aug 2018 11:40

Re: How to Show Folders within a Tree without Parents or Subfolders with a Regexp

Post by pdupreez » 15 Aug 2018 13:15

pdupreez wrote:
jupe wrote:With your example above if you are positioned in this path, "Drive:/Current Dir/" and used this in the XY address bar:

Code: Select all

<curpath>?/md=1 /dx
it should do what you want too, if I am understanding correctly.
Wow, that is awesome. Found 547 folders in a flash.

Now if I only know what it means (My problem, I will go and read up). Thanks to you and highend

Thanks a lot
For posterity, the code can be well understood through the help file. In any case, I understood it as follow:

<curpath> Work on Current Path
? Search
/md=1 Maximum Depth of search
/d Only find Folders
x switch to only return folders that don't contain any matching items

Very neat

Post Reply