# Filters

A "filter" is a criteria (or set of criteria) that an entry either matches or doesn't match. Password Safe allows you to define filters, and display only those entries that match a given filter. You can define a filter for a one-time query, or you can define several filters, naming them and store them persistently, for repeated use. Filters may be either stored along with the database, or externally, for sharing the same filter across several databases.

## Defining a Filter

To define a new filter, select the "View → Filter → New/Edit Filter" menu entry. The following dialog box will be displayed:

As you can see, each Filter consists of one or more rows, where each row defines a criteria on a given field. The conditions defined in each row can be either "and" or "or" the condition defined in the previous row. This allows you to define the following kinds of filters:

1. All entries with a username containing "joe" or "Joe" or "JOE":
2. All entries with a username "Joe" (exactly) created after May 1st 2008
3. All entries with a username containing "joe" or "mary"

As you can see, the filters can be arbitrarily complex.

The columns in the Filter table are as follows:

- '#' - This is the row number. It's displayed for convenience, and cannot be modified.
- '?' - The checkbox in this column determines if the row is active or not. Only active rows are used when applying the filter. Clicking on the checkbox enables/disables the row.
- '+' - Click on this to insert a new row below a given row.
- '-' - Click on this to delete the current row. Note: ince deleting a row is permanent, you might wish to disable it instead.
- 'And/Or' - This allows you to determine the relation of the rule you're adding to the previous rule.
- 'Field' - Select the entry field you're interested in, e.g., username, title, group, notes, etc.
- 'Criteria' - Define the value you're interested in for the selected field. Once you've selected a field, clicking on this will bring up a dialog box allowing you to specify the criteria, which is the displayed in the table.

## Applying a Filter

Once you've defined a filter, clicking on 'Apply' will apply the filter on the entries in the database, while leaving the Set Filter dialog box open. This is useful for fixing and refining the filter based on the results. Clicking on 'OK' will also apply the filter, but will close the Set Filter dialog box.

## Managing Filters

Set/Edit Filter is a good way to work with filters for a one-time task. If, however, you find that you have several filters that you wish to use repeatedly, then you can store them and manage them effectively via the "View → Filter → Manage..." dialog box

The Manage Filters dialog box has two tables. The upper table lists the filters, and the lower table displays the contents of the currently selected filter.

- To add a new filter, click on New. This is equivalent to selecting the "View → Filter → New/Edit Filter" menu entry.
- To edit an existing filter, select is and then click on Edit.
- To apply an existing filter, click on the Apply checkbox in the desired filter's row. Note that only one filter can be applied at a given time.

#### Storing Filters

Filters can be stored either as part of the current database, or externally, as XML files. Storing filters externally is a good way to share filters across databases, whereas storing them as part of the database ensures that potentially sensitive information in the filters' definitions is protected.

- To store filters in an external file: Set the Export checkbox of the filters you wish to store externally, then click on the Export button.
- To store filters in the current database: Set the Copy to DB checkbox, and then click on the Copy button.
- To load an externally stored filter: Click on the Import button.

Note:
Upon Startup, Password Safe searches for a file named autoload_filters.xml in the same directory as the pwsafe.cfg file (by default the directory where Password Safe is installed). If such a file exists, then it is automatically imported and the filters it contains are ready for use. This is useful if you've a set of filters that you wish to share across several databases, without having to explicitly import them each time.