# File name filters

A file name filter stops one kind of action on names that match: uploading `.exe` files, listing files that start with a dot, deleting anything with `final` in its name. The filters of the **Filename Filters** panel of [Restrictions](Prefs-Restrictions.md) apply to every user, on every protocol.

![The Filename Filters panel](Prefs-Restrictions-Filename-Filters/filters.png)

A new server has none: "No filters. Every name is allowed through."

## Adding a filter

A filter is three choices. Make them from left to right and press Enter in the text box:

| Part | Choices |
|---|---|
| what it filters | **Listing**, **Rename**, **Upload**, **Download**, **Delete**, **Any file**, **Any folder** |
| how it compares | **starts with**, **contains**, **ends with**, **matches pattern** |
| the text | what the name is compared with |
| **Allow** | turns the filter around, see [Allow filters](#allow-filters) |

The filter appears above the boxes, in words: "Upload ends with: .exe". The **×** on a filter removes it. Nothing applies until you press **Save** at the bottom.

## What each kind does

| Filter on | A matching name |
|---|---|
| **Listing** | is left out of folder listings. The file is still there; it is only not shown. Folders are never hidden by a Listing filter. |
| **Upload** | cannot be uploaded. The upload is refused, and the log says "Upload attempt was rejected because the block matching names". |
| **Download** | cannot be downloaded |
| **Rename** | cannot be given: nothing can be renamed to it |
| **Delete** | cannot be deleted |
| **Any file** | is shut off as a file for every action: it cannot be uploaded, downloaded or otherwise touched, on any protocol |
| **Any folder** | the same, for folders |

A filter looks at the name alone, the last part of the path, not at the folders it is in. To shut off whole paths, use [Blocked Paths](Prefs-Restrictions.md#blocked-paths).

## How names are compared

| Comparison | Matches when | Upper and lower case |
|---|---|---|
| **starts with** | the name begins with the text | must be the same |
| **contains** | the text is anywhere in the name | must be the same |
| **ends with** | the name ends with the text | does not matter: `.exe` also catches `SETUP.EXE` |
| **matches pattern** | the whole name fits a regular expression, or, with `~` in front of the text, a simple pattern in which `*` stands for any text | as the pattern says |

Because **starts with** and **contains** look at upper and lower case, a filter for `secret` does not catch `Secret`. Add both, or use **matches pattern**.

## Allow filters

With **Allow** ticked, a filter says the opposite: only names that match may pass, and every other name is stopped. One Allow filter "Upload ends with: .pdf" means that nothing but PDF files can be uploaded. With several Allow filters of the same kind and comparison, a name that fits any one of them passes.

## Examples

| Goal | Filters |
|---|---|
| no programs and scripts uploaded | Upload ends with `.exe`, Upload ends with `.bat`, Upload ends with `.sh` |
| hide system files from listings | Listing starts with `.`, Listing ends with `.tmp` |
| only spreadsheets may be uploaded | Upload ends with `.xlsx`, with **Allow** ticked |
| finished reports cannot be deleted | Delete contains `-final` |

## Filters of a single user

A user or a group can have filters of their own in the User Manager. They are added to the ones here: a name must pass both.

## How the filters are stored

The filters are one text, one filter per line, as a code, the text and a semicolon. `:UE:.exe;` is "Upload ends with .exe". The code is the first letter of the kind (`L`, `R`, `U`, `D`; `X` for Delete, `F` for Any file, `DIR` for Any folder) and the first letter of the comparison (`S`, `C`, `E`; `R` for matches pattern). An Allow filter has `!` in front of the text. You see this form in the server's settings file and when settings are exported.
