# Filtered Operations

Normally when a command acts on a folder, the entire contents of that folder are processed as well. For example, if you select a folder and click the **Copy File** button, that folder including all of its contents are copied.

File filters let you control which items within folders are processed. You might want to only copy the image files from sub-folders; or you might want to delete any **.tmp** files but leave all others unaffected. You can use a file filter to accomplish this.

### Functions that support recursive filters

There are a number of functions that support the use of file filters:

* **Copy Files**: When copying or moving files, filtering is enabled by selecting the **Copy Filter** option in the drop-down attached to the **Copy Files** button. The copy filter is local to the Lister, and it remains enabled in that Lister until it is turned off or the Lister is closed.
* **Delete**: When deleting files, filtering is enabled by selecting the **Delete Filter** option in the drop-down attached to the **Delete** button. The delete filter is local to the Lister, and it remains enabled in that Lister until it is turned off or the Lister is closed.
* **Find Files**: The [advanced mode](../basic_concepts/searching_and_filtering/find_files/advanced_find) of the [**Find Files**](../basic_concepts/searching_and_filtering/find_files) tool uses a filter to define the search parameters.
* **File Selection**: The [**Advanced Selection**](../basic_concepts/selecting_files/advanced_selection) dialog lets you select, deselect and hide files in the current file display using a filter.
* **Synchronize**: The **Filter** option in the [**Synchronize**](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/file_operations/filtered_operations/copying_moving_and_deleting_files/copying_updated_files/synchronize.md) tool lets you use a filter to control how synchronize handles sub-folders.
* **Duplicate File Finder**: The **Filter** option lets you control which files are compared when [searching for duplicate files](../additional_functionality/duplicate_file_finder).
* **Attributes**: The [**Attributes**](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/file_operations/filtered_operations/changing_attributes.md) command in the drop-down attached to the **Properties** button lets you use a filter when applying attributes to the contents of sub-folders.
* **Print Folder**: The [**Print / Export Folder Listing**](../additional_functionality/print_folder) command in the **Tools** menu lets you use a filter to control which files are printed to the list.
* **Labels**: You can use the [**Labels**](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/file_operations/filtered_operations/labels.md) system to automatically color or highlight files and folders that match complex filters.

### Defining a filter

When using a filter in a function, there are two ways to define it:

* You can define the filter at the time you actually use it. Functions that let you specify a filter through their user-interface also let you edit it. You can start with a pre-saved one, or build one up from scratch.
* You can select a pre-configured filter from a drop-down list. Filters can be pre-configured and stored using the [Filters](../preferences/preferences_categories/filtering_and_sorting/filters) Preferences page. This lets you build up a repository of useful filters that can be accessed easily throughout the program.

Several of the [internal commands](../reference/command_reference/internal_commands) let you specify a filter on the command line:

* With the name of a filter; for example, `Copy FILTER <filtername>`. In this case, the filter must have been pre-configured and stored.
* With the filter definition itself, in [text format](../reference/textual_filters); for example, `Copy FILTERDEF name match *.jpg`.

### The filter control

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-39ad9422dc09d51b8d8a3dcbb814b10b78435d04%2Ffile_filter.png?alt=media)

This is an example of a dialog that uses the filter control. This particular dialog is displayed when you run the **Copy File** function and the **Copy Filter** option is turned on. Opus displays the filter dialog at the beginning of the copy process, and you can define a new filter in place, or select a pre-configured one from the **Filter** drop-down.

The **Clear** button in the toolbar at the top of the filter control lets you quickly clear the existing filter. If you hold the Shift key down when you click it the filter will be reset to a simple template filter with some common conditions added.

Below the toolbar in the above screenshot is the area where the filter itself is defined, and below the filter control are some controls that are specific to the **Copy** or **Delete** filters:

* **Disable filter after this function:** This lets you have the filter (copy or delete) disabled automatically at the completion of the current function (otherwise the filter will remain in force until you turn it off manually).
* **Select**: This button takes the current filter definition and uses it to select all matching files and folders in the current file display. This lets you see what the results of the filter would be on the current folder before running the command.
* **Skip Filter**: Skips the use of the filter for the current operation, but the filter will remain turned on (unless you also turned on the **Disable filter after this function** option).

Again, these options only apply to the copy and delete filters. When you use filters in other functions (for example, the [**Find**](../basic_concepts/searching_and_filtering/find_files) or [**Synchronize**](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/file_operations/filtered_operations/copying_moving_and_deleting_files/copying_updated_files/synchronize.md) tools), these options will not be displayed.

The dropdown menu to the right of the _Filter:_ label lets you access functions to load, save and manage pre-configured filters. You can also do that via the [Filters](../preferences/preferences_categories/filtering_and_sorting/filters) page in Preferences.

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-5a7261a634cbae3260987703f8617d56a3034e7a%2Ffilter_drop-down.png?alt=media)

More:

[Defining a Filter](filtered_operations/defining_a_filter)\
[Adding, Removing and Editing Clauses](filtered_operations/adding_removing_and_editing_clauses)\
[Filter Clause Types](filtered_operations/filter_clause_types)
