---
schema_version: "1"
id: 1d2b069ba15c33843c30fb5e472a7d1c5fa1eb2b80fa00460e8ebdf7f0de47d5
title: Trigger a Flow When a New File Is Created or Modified Example
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/sftp-connector/2.5/sftp-on-new-file.md
canonical_url: https://docs.mulesoft.com/sftp-connector/2.5/sftp-on-new-file
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 55c8469376abb0d397df64b53075e464dd9de01319d02742780e2a7d6da7c5f8
description: MuleSoft Documentation Site
release: "2.5"
latest: false
---
---
product: SFTP Connector
version: 2.5
---

# Trigger a Flow When a New File Is Created or Modified Example

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Anypoint Connectors for File, FTP, and SFTP provide an **On New or Updated File** operation that
polls a directory for files that have been created or updated. A message is generated for each file
that is found.

The following strategies determine that a file is new:

- Set the **Auto delete** field to **True** to delete each file after it is processed, which causes
  all files obtained in the next poll to be considered new.

- Set the **Move to directory** field to move each file to a different directory after it is
  processed, which achieves the same effect as **Auto delete** but without erasing the file.

- Set the **Watermark** field to pick only files that have been created or updated after the last
  poll was executed.

You can also use a matcher for additional filtering of files.

## Configure the On New or Updated File Operation in Studio

To add and configure the **On New or Updated File** operation in Studio, follow these steps:

1.  In the **Mule Palette** view, search for `sftp` and select the **On New or Updated File**
    operation.

2.  Drag the **On New or Updated File** operation onto the Studio canvas.

3.  In the **General** tab of the operation configuration screen, click the plus sign (**+**) next
    to the **Connector configuration** field to access the global element configuration fields.

4.  Specify the connection information and click **OK**.

5.  Set the **Directory** field to the directory path on which pooled files are contained, for
    example, `test-data/in`.

6.  Set the **Auto delete** field to **True**.

7.  Select the **Watermark** field to enable watermarking.

![On New or Updated File operation configuration in Studio](/mulesoft/current/en-us/sftp-connector/2.5/_images/sftp-newupdated-operation.png)

In the **Configuration XML** editor, the `<sftp:listener>` configuration looks like this:

```xml
<flow name="onNewFile">
    <sftp:listener config-ref="file" directory="test-data/in" autoDelete="true" watermarkEnabled="true">
      <scheduling-strategy>
        <fixed-frequency frequency="1000"/>
      </scheduling-strategy>
    </sftp:listener>

    <flow-ref name="processFile" />
</flow>
```

## See Also

- [SFTP Connector Examples](https://docs.mulesoft.com/sftp-connector/2.5/sftp-examples)

- [Salesforce Help](https://help.salesforce.com)
