watchDirectory Help > Creating New Tasks > Filter Events
Filter Events
On this page you create Filters to limit types of files for which your task starts. Every time watchDirectory detects a new event (a new file, a deleted file, etcetera), all filters are evaluated against the filename of the file or directory. The first filter that evaluates to "true" determines if your task is called for this event.
If you do not create any filters, your task runs for all files and directories.
The list of filters
The area marked 1 on the screenshot shows all created filters.
They are evaluated by watchDirectory from top ("file starts with") to bottom ("extension equals"). A filter can tell watchDirectory to
process the event (indicated by a green checkmark), or to ignore it (shows a red cross).
The screenshot shows a list of 3 filters, instructing watchDirectory to:
- Ignore all events for files (and directories) whose name starts with the letters "XX"
- Ignore all events for files inside directories named "TEMP"
- Process events for files that have a "JPG", "BMP" or "GIF" extension
As watchDirectory will evaluate these filters from top to bottom, and stop when one of them evaluates to true, the order of filters is important. Press the Up and Down buttons to rearrange the filters.
Create a new Filter by pressing the New button. Change the selected filter by pressing Change. If you want to create a new filter that is very much like an existing filter, select the existing filter and press Copy.
Version 4.0 -> 4.1
Previous watchDirectory versions used another method of filtering events.
Your old "Files that trigger events" options are automatically converted to the new "Filter Events" settings when you edit your task.
Files that do not match a filter
With the selection box marked 2 on the screenshot, you tell watchDirectory what to do with files and directories that do not match any filter. In most cases you would select the option to ignore these files.
Filter Scripts
When the normal filters are not flexible enough, you can write a batch file that determines if the event is processed. Several example scripts to get you started are installed in <Install Directory>\ExampleFilterScripts.
Note that most examples need a few little changes before they will work properly.
If you want to use one of the example scripts, make sure to copy it to another directory. Future WatchDirectory installs may otherwise overwrite the script with a new version, overwriting your changes.
See also readme.txt
Testing your filters
The area marked 3 on the screenshot, allows you to enter a filename that is used to test
the filters you created. It will show you which, if any, filter evaluated to true, and if the file in the edit box will be
processed by your task.
The "Test Result" column in the area marked 1 also shows the result of each individual filter.
When all filters evaluate to "false", the result of the test is the selection you make in the "Files that do not match a filter" box (marked 2).