How to exclude files
************************

In some cases, it may be useful to exclude certain files, or a certain type of files, from your search results.

An exclusion filter can help speed up the search for large amounts of data. If, for instance, certain subpaths are not relevant to a search, TreeSize can simply skip them. It is also possible to prevent certain data from appearing in the result set at all.

An example of this is system files that should not be deleted or moved in most cases. In order not to display such files in the first place, a corresponding exclusion filter can be defined.

There are two ways to create an exclude filter:

Using global search filters
==============================

The easiest way to exclude files from searching is to add them to the list of global search filters.

Global search filters, as the name suggests, can be defined for the entire application. Unlike the individual search definitions, they are valid for all searches, but can be turned on or off for each search separately.

Global search filters can be activated and adjusted in the options dialog under "Exclude filter".


As part of the filter definition
===================================

You can also exclude certain files within the advanced search directly, using another filter. Suppose you already have an existing filter, for example, a minimum file size.

This can be combined via the ``And`` conjunction with another filter, which excludes certain files (e.g. "System Files") from the search.

The exclude filter in this example is defined as follows:

- Select **File Type** in the first selection box
- Select **does not equal** in the second selection box
- Select **System Files** in the third selection box

Make sure that the original filter and the exclusion filter are combined via ``And``, meaning that the two have a common parent that contains the ``And`` selection.

.. image:: /images/TreeSize-FileSearch_Excludefilters.png
   :width: 100%
   :align: center

Using this method, even more complex combinations can be created.

For example, multiple inclusion filters might already be combined via ``Or`` (e.g. ``file name = "one file" OR file name = "another file"``).

To connect this existing combination with an exclusion filter, the complete ``Or`` group must be combined with the new exclusion filter with ``And``.

The Exclude System Files template shows such an example, which searches for different file names but excludes system files at the same time.