Shortcut or Filter for "OR" operator?

Discussion related to "Everything" 1.5 Alpha.
Post Reply
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Shortcut or Filter for "OR" operator?

Post by David.P »

Hello Forum,
is there a way to link a significant number of search terms with
OR
without having to type
OR
between all search terms?

Best regards
David
void
Developer
Posts: 16745
Joined: Fri Oct 16, 2009 11:31 pm

Re: Shortcut or Filter for "OR" operator?

Post by void »

| = OR

For example:

foo|bar|baz|qux
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by David.P »

Thank you -- that's clear.
I mean, if for example I have 20 or 30 search terms in the clipboard and I'd like to do a quick
OR
search with these.

Is that possible without having to type the search operator between all search terms?
void
Developer
Posts: 16745
Joined: Fri Oct 16, 2009 11:31 pm

Re: Shortcut or Filter for "OR" operator?

Post by void »

How are the terms separated on the clipboard? with a space? with a new line?

With a space use:
#substitute:#clipboard:," ","|"

With a new line use:
#substitute:#clipboard:,&\r:&\n,"|"



If you want to expand these searches, prefix them with a / and press ENTER in the search box.
For example:
Set the search to:
/#substitute:#clipboard:," ","|"
Copy your word list to the clipboard.
Press ENTER in the Everything search box.

#substitute:
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by David.P »

Ah, that's fantastic. Can I build a filter from this as well, since the case occurs often for me?

My search terms are typically strings consisting only of letters and numbers. The search terms are separated from each other typically by a mixture of multiple spaces, new lines and/or tabs.
Do I have to clean up such a list of strings beforehand, so that e.g. there is exactly one space between the search terms, or can the
substitute
function take care of that?
void
Developer
Posts: 16745
Joined: Fri Oct 16, 2009 11:31 pm

Re: Shortcut or Filter for "OR" operator?

Post by void »

You can add these searches as a filter from Search -> Add to filters....


To convert newlines, tabs and spaces to |
and replace multiple | with a single |
and trim left and right |
please try the follow:

#trim:#regex-replace:<#regex-replace:<#clipboard:,"[\r\n\t ]","|">,"\|+","|">,"|"

#regex-replace:
#trim:
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by David.P »

Thank you so much, this is amazing (again).

When I enter this code in the search box.
#trim:#regex-replace:<#regex-replace:<#clipboard:,"[\r\n\t ]","|">,"\|+","|">,"|"

...then it seems that the clipboard is being monitored, and as soon as I copy my (untidy) collection of search terms to the clipboard, the search is performed, correct?

I have created a filter as follows:

Image

However, I seem to have done something wrong there again, because the filter doesn't seem to work, neither with the search terms in the clipboard, nor in the search box?
void
Developer
Posts: 16745
Joined: Fri Oct 16, 2009 11:31 pm

Re: Shortcut or Filter for "OR" operator?

Post by void »

Everything will monitor the clipboard when using #clipboard: and update your search when it changes.



Please make sure your filter is activated from the Search menu, Filter bar (View -> Filters), right clicking the status bar or filter keyboard shortcut.

Please note your filter search terms are not highlighted.
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by David.P »

This is incredible. I can simply highlight my search term list in Excel (or somewhere) and immediately all matching files are displayed in Everything.

I still have something wrong with the filter though, because it doesn't return any results when used like this, with the search terms in the search box:

Image


Also, can I modify the search such that for each of the search terms not all matching documents are displayed, but only one document (e.g. the most recent document)?
void
Developer
Posts: 16745
Joined: Fri Oct 16, 2009 11:31 pm

Re: Shortcut or Filter for "OR" operator?

Post by void »

Please edit your filter and change:
The Search to:
#trim:#regex-replace:<#regex-replace:<#<:search:#>:,"[\r\n\t ]","|">,"\|+","|">,"|"
The Macro to:
orsearch<search>

Now Everything will use the words in your search box instead of the clipboard.



Also, can I modify the search such that for each of the search terms not all matching documents are displayed, but only one document (e.g. the most recent document)?
doc: #replaceterms:<#trim:<#regex-replace:<#regex-replace:<#<:search:#>:,"[\r\n\t ]","|">,"\|+","|">,"|">,#<:<#term: col1:=#term:>#>:> addcol:col1 sort:col1;dm distinct:col1

doc: = match document file types. -remove this if you want any files/folders.
#replaceterms: = rewrite each term to set column1 with the current term when it matches.
addcol:col1 = optionally show the "column 1" column -remove this if you dont want to see column 1.
sort:col1;dm = presort the distinct: search so we match the most recently modified files.
distinct:col1 = match each term once.
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by David.P »

Wow... :o

This filter works like a charm now.

However the latter (deduplicate results) seems to do nothing for me at the moment. Is the syntax correct? There seems to be a little difference behind
#trim:#

Image
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by David.P »

Oh, my bad. The code

doc: #replaceterms:<#trim:<#regex-replace:<#regex-replace:<#<:search:#>:,"[\r\n\t ]","|">,"\|+","|">,"|">,#<:<#term: col1:=#term:>#>:> addcol:col1 sort:col1;dm distinct:col1


..is supposed to go in a Filter. That WORKS!!!!

Time and again it's incredible how ingenious Everything is 🤯🙏
David.P
Posts: 200
Joined: Fri May 29, 2020 3:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by David.P »

I don't have words about how awesome this is.

Image

I dare hardly ask: could another column be added that tells the number of occurrences of each (deduplicated) search result?

And... can I assign custom names to the added column(s)?
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Shortcut or Filter for "OR" operator?

Post by NotNull »

David.P wrote: Thu Jul 27, 2023 1:22 pm And... can I assign custom names to the added column(s)?
Not yet, see [Suggestion] Column labels
Post Reply