> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Filesystem: Resolve destination filename conflict

> Ensures a destination path is available on the filesystem. If a file already exists at the path, applies a conflict resolution strategy (for example, appending a counter: foo.json becomes foo-2.json).

Use this when you are about to write a file and want to avoid overwriting something that is already there. It takes the destination path you give it, checks the chosen filesystem connection, and if a file already exists at that path it applies the conflict resolution strategy you pick to produce a free path instead. For example, `exports/orders.json` becomes `exports/orders-1.json` when the original is taken. When the path is already free, it is returned unchanged. The path it returns is meant to be passed on to a step that writes, copies, or moves the file, so the same conflict handling is also available directly on the Filesystem write, copy, and move transformers.

This documentation describes: [Schema](/schemas/mapper/filesystem-ensure-destination)

## Fields

**Filesystem connection**

Required

The storage location to check for existing files, such as a local folder, FTP or SFTP server, or cloud bucket. It looks here to decide whether a file is already present at the path. See [filesystem connections](/references/filesystem) for how to set one up.

See the [filesystem](/references/filesystem) reference.

**When the file exists**

Required

The strategy that produces an available path when the chosen one is already taken. The available option, "Add an increasing number to the filename", appends a counter that grows until a free name is found (`orders.json`, then `orders-1.json`, then `orders-2.json`, and so on). You control the naming pattern, the number format, the starting number, and whether a number is always added even when the path is already free. See [file actions](/references/filesystem-ensure-destination) for the strategy and its settings.

See the [filesystem-ensure-destination](/references/filesystem-ensure-destination) reference.

## Sample data

This feature does not transform a value on its own. It looks at the live filesystem to decide whether a path is already in use, then hands back a safe path, so there is no fixed before/after to show: the same input can return a different result depending on what files already exist. Below is a typical configuration and how it behaves.

| Field | Value |
| - | - |
| Filesystem connection | A connection where `exports/orders.json` already exists |
| When the file exists | Add an increasing number to the filename (default pattern, starting at 0) |

With this configuration, feeding in the path `exports/orders.json` returns `exports/orders-1.json`, because the original name is already taken. If `exports/orders.json` does not exist yet, the same path is returned untouched.

```json Configuration theme={null}
{
  "prototype": "filesystem-ensure-destination",
  "parameters": {
    "filesystem": { "prototype": "<your-filesystem-connection>", "parameters": {} },
    "ensureDestination": {
      "prototype": "increase-counter",
      "parameters": {
        "template": "{dirname}/{filename}-{counter}.{extension}",
        "format": "%d",
        "start": 0,
        "alwaysAddCounter": false
      }
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.