> For the complete documentation index, see [llms.txt](https://docs.couchdrop.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.couchdrop.io/automations/conditional-filtering.md).

# Conditional Filtering

Learn about conditional filtering for Automations

## Overview

Conditional filtering lets you control how files move through a Couchdrop Automation based on specific conditions.

Conditions can evaluate properties such as the filename, modification time, directory, triggering user or group, and Automation Variable values. Based on the result, the workflow can continue down a **True** or **False** branch.

This allows a single workflow to handle multiple scenarios without creating separate Automations for each outcome.

<figure><img src="https://391958821-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FpokYqd27yrOUxIBhyvbF%2Fuploads%2FQe9ybPEHjhi7T6XWkLOg%2Fimage.png?alt=media&amp;token=80b95cd8-6994-4baa-aae2-78ec2a1f0770" alt=""><figcaption></figcaption></figure>

### Adding a condition

Conditions are configured in the Automation builder.

Click the **+** where you want to add the condition, then select **Conditions**.

The condition evaluates the current file or workflow context and routes processing through either the **True** or **False** branch.

### True and False branches

Conditions support separate **True** and **False** branches.

When Couchdrop evaluates a condition:

* The **True** branch runs when the condition matches.
* The **False** branch runs when the condition does not match.

Each branch can contain its own actions and additional workflow steps.

For example, if a **Filename matches** condition checks for `*.txt`:

* Files matching `*.txt` can follow the **True** branch and be attached to an email.
* Files that do not match can follow the **False** branch and perform a different action, such as deleting the file.

This allows a single workflow to define what should happen for both outcomes of a condition.

## Available conditions

Couchdrop supports the following condition types:

<table data-search="false"><thead><tr><th>Condition</th><th>Description</th></tr></thead><tbody><tr><td><strong>Filename matches</strong></td><td>Matches the filename against a pattern.</td></tr><tr><td><strong>File modtime</strong></td><td>Checks whether the file's last modification time matches the configured condition.</td></tr><tr><td><strong>Directory matches</strong></td><td>Matches the directory against a pattern.</td></tr><tr><td><strong>User matches</strong></td><td>Matches the user who caused the File Action to trigger.</td></tr><tr><td><strong>Group matches</strong></td><td>Checks whether the user who caused the File Action to trigger belongs to a specified group.</td></tr><tr><td><strong>Automation Variable matches</strong></td><td>Compares an Automation Variable against a text pattern.</td></tr><tr><td><strong>Complex Condition</strong></td><td>Evaluates multiple conditions together in a single step.</td></tr></tbody></table>

### Filename matches

Use **Filename matches** when the workflow should branch based on a filename pattern.

For example, you can configure a condition to match `*.txt`. Files matching the pattern follow the **True** branch, while files that do not match follow the **False** branch.

### File modtime

Use **File modtime** to evaluate a file based on its last modification time.

File modification conditions support:

* **Before**
* **After**
* **In the last**
* **Older than**

For example, a condition configured as **Older than 7 days** will evaluate as True for files modified more than seven days ago.

### Directory matches

Use **Directory matches** when the workflow should branch based on the directory containing the file.

The directory is matched against the configured pattern. Files in matching directories follow the **True** branch, while files that do not match follow the **False** branch.

### User matches

Use **User matches** to evaluate the user who caused the File Action to trigger.

This allows subsequent actions to differ depending on which user triggered the workflow.

### Group matches

Use **Group matches** to check whether the user who caused the File Action to trigger belongs to a specified group.

The workflow can then route the file through the appropriate **True** or **False** branch based on group membership.

### Automation Variable matches

Use **Automation Variable matches** when the workflow should branch based on the value of an Automation Variable.

When creating the condition, configure:

* **Select Automation Variable to compare**: Select the Automation Variable whose value you want to evaluate. Automation Variables must contain text to be compared.
* **Please enter the text to match against**: Enter the text that the selected variable should match.
* **Regex pattern**: Optionally use a regular expression when matching the variable.
* **Test your regex**: Enter example text to verify whether your regular expression matches as expected.

The condition evaluates the selected Automation Variable and routes the workflow through the **True** or **False** branch based on the result.

## Complex Conditions

Use a **Complex Condition** when you need to evaluate multiple conditions together before deciding which branch of a workflow should run.

A Complex Condition contains two or more individual conditions and combines their results using either **And Condition** or **Or Condition**.

When creating a Complex Condition, enter a **Label**, choose the **Condition type**, then add the conditions you want to evaluate.

### And Condition

Choose **And Condition** when **every condition must match**.

For example, you could configure:

* **Filename extension** **Matches** `txt`
* **Filename** **Matches** `*finance*`

Both conditions must match for the Complex Condition to return **True**. If either condition does not match, the workflow follows the **False** branch.

### Or Condition

Choose **Or Condition** when **any one of the conditions can match**.

For example, you could configure several filename conditions for different expected file names or patterns.

If at least one condition matches, the Complex Condition returns **True**. The workflow follows the **False** branch only when none of the conditions match.

### Pattern matching

Filename and directory conditions support wildcard pattern matching:

| Pattern  | Matches                                     |
| -------- | ------------------------------------------- |
| `*`      | Any number of characters                    |
| `?`      | Any single character                        |
| `[seq]`  | Any single character contained in `seq`     |
| `[!seq]` | Any single character not contained in `seq` |

Conditions using **Automation Variable** use regular expression pattern matching instead.

## Using conditions in workflows

Conditions can be used anywhere in an Automation where different processing should occur based on the file or workflow context.

Because both **True** and **False** branches can contain actions, conditions can be used to build workflows that handle multiple outcomes within the same Automation rather than requiring a separate workflow for each scenario.
