Using the parent: function with multiple folders

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
ymorgan
Posts: 3
Joined: Wed Dec 23, 2020 3:42 pm

Using the parent: function with multiple folders

Post by ymorgan »

I would like to search for files and folders in multiple locations, but restrict the search to not include subfolders. So I tried the following:

Code: Select all

parent:<"C:\Music"|"C:\Documents"> test
Unfortunately, that does not return the correct results. I've also tried without the grouping characters (i.e., "<>") which also doesn't work.

Can the parent: function take multiple paths?

Also, I notice that the parent: function doesn't work with single folder names (e.g., parent:"Music\"). I found the following example as an alternative:

Code: Select all

\Music !*\Music*\*\*
I've tried it and it works. It seems to work even with subfolders 3 or 4 levels deep. By looking at the code, it seems that it would only restrict 2 levels deep. Does that code explicitly restrict the search to not include all subfolders, no matter the depth?
therube
Posts: 4977
Joined: Thu Sep 03, 2009 6:48 pm

Re: Using the parent: function with multiple folders

Post by therube »

<parent:C:\Music | parent:C:\Documents> test


> Can the parent: function take multiple paths?
Appears not, at least not directly to a single parent:.

> parent: function doesn't work with single folder names (e.g., parent:"Music\")
Correct, it needs a path, C:\tmp\Music.
void
Developer
Posts: 16751
Joined: Fri Oct 16, 2009 11:31 pm

Re: Using the parent: function with multiple folders

Post by void »

Sub expressions on parent: will be supported in a future release, eg:
parent:<"C:\Music"|"C:\Documents"> test

For now, you will need to specify multiple parent: terms (as therube has already mentioned), eg:
parent:"C:\Music" | parent:"C:\Documents" test
ymorgan
Posts: 3
Joined: Wed Dec 23, 2020 3:42 pm

Re: Using the parent: function with multiple folders

Post by ymorgan »

Thank you @therube and @void for confirming! The code @therube posted works perfectly. I can now restrict the search to multiple folders and not include subfolders, all on one line. I also found that combining single folder names and full paths in the group works, something like:

Code: Select all

<\"Downloads" !*\"Downloads"*\*\*|\Scripts !*\Scripts*\*\*|parent:"C:\Music"|parent:"C:\Documents"> test
@void: great to hear about the future update plans. Thanks for creating such an amazing piece of software!
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Using the parent: function with multiple folders

Post by NotNull »

ymorgan wrote: Wed Dec 23, 2020 4:13 pm

Code: Select all

\Music !*\Music*\*\*
I've tried it and it works. It seems to work even with subfolders 3 or 4 levels deep. By looking at the code, it seems that it would only restrict 2 levels deep. Does that code explicitly restrict the search to not include all subfolders, no matter the depth?
Clever!
And yes, that will restrict your search to files (and folders) that have a folder named "music" as their parent.
There is one thing to keep in mind, however:
If you have a folder c:\music\something\music\ , it will be excluded from your results because of the \music\ earlier in the path.

I needed this a while ago and the best I could come up with was a regular expression version:

Code: Select all

regex:"\\music\\[^\\]+$"
(basically saying to search for all names with \music\ and no "\" after that. Just like you did :)

(this requires Match path when a search term contains a path separator to be enabled, btw (menu: Tools > Options > Search).
But you have this enabled already or else your search wouldn't return any results
ymorgan
Posts: 3
Joined: Wed Dec 23, 2020 3:42 pm

Re: Using the parent: function with multiple folders

Post by ymorgan »

@NotNull: Great tip, thanks! I'll certainly be making use of it.
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Using the parent: function with multiple folders

Post by NotNull »

Added to that: if you want to search for files taht have a parent named music or documents, you can use this

Code: Select all

regex:"\\(music|documents)\\[^\\]+$"

To speed up this search (as it might take a while)

Code: Select all

\music\|\documents\     regex:"\\(music|documents)\\[^\\]+$"
This will - fast- exclude most irrelevant folders before starting the regular expression pattern search on the remaining folders.
Post Reply