Filtering out directories on search line

General discussion related to "Everything".
Post Reply
N1755L
Posts: 9
Joined: Wed Mar 09, 2016 11:30 pm

Filtering out directories on search line

Post by N1755L »

Hello,

I've searched but can't find an answer, the closest I've found was that I could, in the settings, exclude directories, but if I don't want to exclude directories "permanently" this way (I know, I could just go remove it afterward), but rather, if I want to put in a search string that would also specify a directory to exclude from the results, is there a search or regex syntax I can use to specify the exclusion of directories in the search window?

Thank you.
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filtering out directories on search line

Post by void »

Use the NOT Operator: ! with the path.

For example, to exclude C:\Program Files, search for:
!"c:\program files\"

Notes:
! = NOT
Use double quotes to escape spaces.

For example, to exclude C:\Program Files, C:\Program Files (x86) and C:\Windows, search for:
!"c:\program files\" !"c:\program files (x86)\" !c:\windows



If you find these searches useful, please consider adding them as a filter:
  • In Everything, from the Search menu, click Add to Filters....
    Change Name to: My exclude folders
    Change Search to: !"c:\program files\" !"c:\program files (x86)\" !c:\windows
    Click OK.
Filters can be activated from the Search menu, Filter bar (View -> Filters), right clicking the status bar, filter macro or filter keyboard shortcut.
N1755L
Posts: 9
Joined: Wed Mar 09, 2016 11:30 pm

Re: Filtering out directories on search line

Post by N1755L »

Thank you void,

I'd figured that much, but I was thinking about excluding all recycle bins from the search results, so I'd tried !"*\recycl*bin*\", but that doesn't work.

*****

As I was writing this reply... : "However, if I put !"Y:\recycl*bin*\", that works for the recycle bin for Y drive. How would I wildcard for all drives?"

As I was writing that in my reply here, I noticed that I'd forgot to place a colon after the first wildcard, and so now that I'm using !"*:\*recycl*bin*\*", it works like a charm!

I asked here because I thought that there likely was some kind of extra, or special, syntax to specify or differentiate between filenames and directory names (so I thought I'd be wasting my time trying all kinds of syntax combinations), but from what I see here, there obviously is not.

Thanks for your help!
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filtering out directories on search line

Post by void »

Wildcards match the entire filename.
You would need a * at the end.
Note the $ at the start of $RECYCLE.BIN

Please try the following wildcard search to exclude all $RECYCLE.BIN folders:
!?:\$recycle.bin\*
N1755L
Posts: 9
Joined: Wed Mar 09, 2016 11:30 pm

Re: Filtering out directories on search line

Post by N1755L »

void wrote: Mon May 17, 2021 5:46 am Wildcards match the entire filename.
You would need a * at the end.
Note the $ at the start of $RECYCLE.BIN

Please try the following wildcard search to exclude all $RECYCLE.BIN folders:
!?:\$recycle.bin\*

Oh, that's right, I forgot that I can use the "?" here, since the drive letter is always one character. And yes, I thought I might be able to remove that last wildcard, but I noticed that I needed that last wildcard.

What's working for me now is: !"*:\*recycl*bin*\*"

I see from your response that I don't need those quotation marks, and then I tried your previous suggestion about filters in the Everything Search>Add to Filters menu item, I created this filter and a keyboard shortcut, and that works beautifully and fast, however, I don't think I'm going to be wanting to make use of these filters 'cause it's scary... if I forget to use filters for a few months, I could possibly forget that I'd activated a filter, and then end up pulling my hair out for hours (heaven forbid days) because there is no indication, nothing I can see that would indicate that the filtering is active, not in the title bar, nor in the bottom status bar, so I might not notice that I'm excluding certain results that I'm trying to find: http://postimg.cc/5HbbKcw1

I would like to suggest to the author that if any such filters are active, they should show up right in the title bar, as you can see in the above photo, maybe the title bar would say something like: "*.mp4 - Everything -- Exclude filter active: !?:\*recycl*bin*\*" or "*.mp4 with Exclude Filter active: !?:\*recycl*bin*\* -- Everything"

Lastly, you say "Note the $ at the start of $RECYCLE.BIN", notice that I didn't use the $ in my Exclude and it still works fine, but since you brought my attention to it, I expect that it's a cautionary note you're pointing out to me? The $ character in front of a filename makes the file normally invisible to Explorer? Or was that $ character a file or folder that could be accessed remotely over the network? I forget now. But I certainly am interested as to why you make note of it.
void
Developer
Posts: 16897
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filtering out directories on search line

Post by void »

notice that I didn't use the $ in my Exclude and it still works fine, but since you brought my attention to it, I expect that it's a cautionary note you're pointing out to me?
I was only pointing out the missing $ in your initial post.

Searching for..

!?:\$recycle.bin\*
-or-
!?:\*recycle.bin\*

..are both fine and will both match your $recycle.bin folder.


Searching for \recycle.bin will never match \$recycle.bin



Double quotes are only required if there are spaces in your filename.
For example, everything treats
abc 123
as:
abc AND 123

while "abc 123"
is treated as:
abc<literal space>123
N1755L
Posts: 9
Joined: Wed Mar 09, 2016 11:30 pm

Re: Filtering out directories on search line

Post by N1755L »

Got it.

I had the bottom-right part of the window pushed slightly off the bottom of my second screen, so I didn't see/notice the active filter notification at the very bottom-right part of the Everything window. Now I can use filters :D
Post Reply