Filter functions

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
void
Site Admin
Posts: 4851
Joined: Fri Oct 16, 2009 11:31 pm

Filter functions

Post by void » Thu Nov 03, 2016 9:34 am

A filter function is a special filter macro that takes one parameter that can dynamically build a filter search.

Filter functions have been added to Everything 1.4.1.790b:

http://www.voidtools.com/Everything-1.4.1.790b.x86.zip
http://www.voidtools.com/Everything-1.4.1.790b.x64.zip

To create a filter function, append the filter macro name with:
<name>

All occurrences of name: in the filters search will be substituted with the parameter passed to your macro.

For example, to search for files with the content "foo bar", where the files could be utf8 or ansi, you would have to search for:
utf8content:"foo bar" | ansicontent:"foo bar"

With filter functions, you can create a filter (from Search -> Add to filters...) with the macro:
ct<search>

and with the filter search:
utf8content:search: | ansicontent:search:

when searching for ct:"foo bar" the search will be replaced with:
utf8content:"foo bar" | ansicontent:"foo bar"

mwsm
Posts: 21
Joined: Thu Feb 28, 2013 2:01 am

Re: Filter functions

Post by mwsm » Thu Nov 03, 2016 11:39 pm

This is an excellent and powerful new feature! For example, I am now able to create a custom Whole Word filter that includes the underscore character as a word boundary, something I've long missed in Everything. I set up the Filter like this:

Code: Select all

Search: regex:"(?:\b|_)word:(?:\b|_)"
Macro: ww<word>
Thank you!

harryray2
Posts: 100
Joined: Sat Oct 15, 2016 9:56 am

Re: Filter functions

Post by harryray2 » Sun Nov 06, 2016 10:28 am

I'm probably being dense, I don't quite get it....is it possible to put a screenshot up with an example?

void
Site Admin
Posts: 4851
Joined: Fri Oct 16, 2009 11:31 pm

Re: Filter functions

Post by void » Mon Nov 07, 2016 9:03 am

The search is now used as the filter parameter when a filter with a macro function is active in Everything 795b:
http://www.voidtools.com/Everything-1.4.1.795b.x86.zip
http://www.voidtools.com/Everything-1.4.1.795b.x64.zip

For example, if you have the filter with the search:
parent:search:
and the macro:
myparent<search>

When this filter is active, the search: part is substituted with the current search.
So when searching for c:\windows with the parent filter active, the search is replaced with:
parent:c:\windows

Image
Image

hansolocambo
Posts: 5
Joined: Mon Oct 09, 2017 9:30 am

Re: Filter functions

Post by hansolocambo » Mon Oct 09, 2017 9:35 am

I'm sure this is extremely powerful and even "simple", but sadly it's not accessible to the "ordinary people" who never write a line of code and are used to intuitive UIs with cells to be filled in. :oops:

horst.epp
Posts: 184
Joined: Fri Apr 04, 2014 3:24 pm

Re: Filter functions

Post by horst.epp » Mon Oct 09, 2017 1:06 pm

hansolocambo wrote:I'm sure this is extremely powerful and even "simple", but sadly it's not accessible to the "ordinary people" who never write a line of code and are used to intuitive UIs with cells to be filled in. :oops:
There is no code to write and the examples above are easy to follow even for beginners.
If that is to much you should probably stay with Windows search or only use the basic Everything features.

Stamimail
Posts: 698
Joined: Sat Aug 31, 2013 9:05 pm

Re: Filter functions

Post by Stamimail » Thu Jun 28, 2018 7:15 pm

There is no code to write and the examples above are easy to follow even for beginners.
I don't think so.
Anyway,
<search>
search:
This Syntax where was it taken from? What was its inspiration?

hansolocambo
Posts: 5
Joined: Mon Oct 09, 2017 9:30 am

Re: Filter functions

Post by hansolocambo » Fri May 24, 2019 11:26 am

horst.epp wrote:
Mon Oct 09, 2017 1:06 pm
There is no code to write and the examples above are easy to follow even for beginners.
If that is to much you should probably stay with Windows search or only use the basic Everything features.
If the most helpful things that come to your mind look like this, keep it to yourself.

horst.epp
Posts: 184
Joined: Fri Apr 04, 2014 3:24 pm

Re: Filter functions

Post by horst.epp » Fri May 24, 2019 4:13 pm

hansolocambo wrote:
Fri May 24, 2019 11:26 am
horst.epp wrote:
Mon Oct 09, 2017 1:06 pm
There is no code to write and the examples above are easy to follow even for beginners.
If that is to much you should probably stay with Windows search or only use the basic Everything features.
If the most helpful things that come to your mind look like this, keep it to yourself.
You said you want "intuitive UIs with cells to be filled in"
So if that is not available use the basic features of Everything or some other fancy GUI based tool.
For most "simple" usage its all you need.
And I still will comment :)

nod5
Posts: 15
Joined: Fri Aug 19, 2016 9:12 pm

Re: Filter functions

Post by nod5 » Sat May 25, 2019 1:20 pm

hansolocambo wrote:
Mon Oct 09, 2017 9:35 am
I'm sure this is extremely powerful and even "simple", but sadly it's not accessible to the "ordinary people" who never write a line of code and are used to intuitive UIs with cells to be filled in. :oops:
Maybe this helps.

How to create and use you own filter functions

First we can ask: Why use a filter function? What's the point? Answer: use it to simplify a complex search that you do regularly but that Everything doesn't already have any simple menu option or short macro for.

Example where you don't need to create a filter function.
Everything already has the built in filter Compressed to search for compressed files. So if you type zip:food Everything lists files that are compressed (files with the extensions .zip .7z .rar ...) and has food in the filename. In this example zip: is the built-in macro for the filter. You type the macro to tell Everything what filter to apply.

Example where it can help to make a filter function
Imagine you regularly want to do some searches that apply several wildcards, functions and/or modifiers.
(See https://www.voidtools.com/support/everything/searching for built in search syntax.)
For example imagine that you regularly want to search for files in the folder C:\Windows or its subfolders with file extension .txt or .log
To do that first enable Match Path in the Search menu and then type C:\Windows ext:txt;log test

On my computer I get these results
(To see the screenshots either log in to voidtools forum or view them on imgur here https://imgur.com/a/vZT4ELm )
1.png

A filter function can do the same search with less typing.
To create a filter function go to Search > Organize Filter... > New
The New Filter window is now shown. Enter the details shown in this screenshot and press OK.
2.png

Now type win:test in Everything to use the filter we created.

The results are the same as before
3.png

What happens is that Everything behind the scenes transformed win: into C:\Windows ext:txt;log

Three important things to remember when you make filter functions

1. win (blue color in the screenshot). This is the custom macro name. We later type win: in Everything to use the macro. Note that there should be no colon when we create the filter (no colon in the blue part), but a colon when we use the filter.

2. <search> (green color) represents any string the user types after win:

3. search: (red color) also represents any string the user types after win:

Question: why <search> in one field and search: in the other? Answer: I don't know, but that's the way it has to be. :)

To make your own filter functions use my example above but change the blue and pink parts. Examples:
- Change the blue text to xyz and you can later in Everything type xyz: to search with the filter function. For example xyz:test
- Change the pink text to D:\ ext:txt size:<25000 search: to make a filter that searches for files on drive D:\ with extension .txt and a size smaller than 25000 bytes.
- See https://www.voidtools.com/support/everything/searching for all the built in search command you can combine when you make a filter function.

Filter functions without macros

You don't have to use macros. You can instead toggle the filter function on/off in the Search menu or through a hotkey that you set up in the Add Filter window.
You do not have the required permissions to view the files attached to this post.

Stamimail
Posts: 698
Joined: Sat Aug 31, 2013 9:05 pm

Re: Filter functions

Post by Stamimail » Sun May 26, 2019 7:56 pm

@nod5, very nice.
I still think there is something to improve here.
I liked the most this sentence:
nod5 wrote:
Sat May 25, 2019 1:20 pm
Question: why <search> in one field and search: in the other? Answer: I don't know, but that's the way it has to be. :)
How to produce a clear syntax without causing confusion (like avoid using signs with double meaning and so), is a work of art.
I had a discussion once about such:
Syntax of functions

Post Reply