> For the complete documentation index, see [llms.txt](https://doc.wearepatchworks.com/product-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape/configuring-sftp-connections/valid-ftp-commands/rename-ftp-command.md).

# rename (FTP command)

### Overview

The `rename` command changes the name of specified files. You can [rename single/multiple files and leave them in the same directory](#renaming-but-not-moving-a-file), or you can [rename files into a different directory](#renaming-and-moving-a-file).

## Need to know

* No content is loaded into the flow. A boolean value is returned to indicate a successful/failed file operation.
* Regular expressions are supported in filenames.

## Connection settings

When [configuring an SFTP connector](/product-documentation/process-flows/building-process-flows/process-flow-shapes/standard-shapes/connector-shape/configuring-sftp-connections.md), three fields should be updated:

| FTP command                                                                             | Root                                              | Path                                            |
| --------------------------------------------------------------------------------------- | ------------------------------------------------- | ----------------------------------------------- |
| FTP command followed by the required directory and name for the file when it's renamed. | The common root to source and target directories. | The source directory and file(s) to be renamed. |

## Examples

* [Rename but don't move a file](#renaming-but-not-moving-a-file)
* [Rename & move a file](#renaming-and-moving-a-file)

### Renaming but not moving a file

* [Scenario](#scenario)
* [The steps](#the-steps)

#### Scenario

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><p>Our process flow is configured as below:</p><p><img src="/files/qN2g17MJQH0LUfftEfNY" alt="" data-size="original"></p></td><td><a href="/files/rI8jPerjv9MFfSCvdBbq">/files/rI8jPerjv9MFfSCvdBbq</a></td></tr><tr><td><p>In this flow, we need to rename a file named <code>hello.txt</code> in <code>/myfiles/folderC</code> to <code>goodbye.txt</code>:<br><br><img src="/files/IIBtoFNllW0AUVX1qeAD" alt=""></p><p>We want the renamed file to end up in the same directory.</p></td><td><a href="/files/2vpVY6Q37YrYqTgeZirK">/files/2vpVY6Q37YrYqTgeZirK</a></td></tr></tbody></table>

#### The steps

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><p><strong>Connector settings</strong></p><p>Our SFTP shape is configured as follows:</p><p><img src="/files/fTgYYKDZNLjW5rgY5SmL" alt="" data-size="original"></p><ul><li>Use the <code>SFTP GET user pass</code> endpoint.</li><li>Start looking for the file to rename from the <code>root</code>, which is defined as: <code>/myfiles/</code></li><li>Check the <code>path</code> for the file to rename, which is defined as: <code>folderC/hello.txt</code></li><li>Rename the file to the directory/name provided immediately after the <code>ftp command</code>. This is defined as: <code>rename:folderC/goodbye.txt</code></li></ul></td><td><a href="/files/oMb9sRQ3X0NcUlY4i8Mk">/files/oMb9sRQ3X0NcUlY4i8Mk</a></td></tr><tr><td><p><strong>Payload &#x26; SFTP server</strong></p><p>When the process flow is run, the payload for our SFTP shape shows just a <code>1</code>:</p><p><img src="/files/phvQnMVVkyh1BdgGl47J" alt="" data-size="original"></p><p>A <code>1</code> indicates a successful response from your remote server. A <code>0</code> indicates an unsuccessful response.</p><p>On our remote server, <code>hello.txt</code> is now named <code>goodbye.txt</code> (still in <code>/folderC</code>):<br><br><img src="/files/YBmweuzfszl8MnYz33pS" alt=""></p></td><td><a href="/files/J6YFhcQQMgUmK2sBQwdu">/files/J6YFhcQQMgUmK2sBQwdu</a></td></tr></tbody></table>

### Renaming & moving a file

* [Scenario](#scenario)
* [The steps](#the-steps)

#### Scenario

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><p>Our process flow is configured as follows:</p><p><img src="/files/9G04IVsf8aCykiOFRtox" alt="" data-size="original"></p></td><td><a href="/files/rI8jPerjv9MFfSCvdBbq">/files/rI8jPerjv9MFfSCvdBbq</a></td></tr><tr><td>In this flow, we need to <code>rename</code> <code>/myfiles/folderE/hello.txt</code>:<br><br><img src="/files/7sfUo4GAokzhlSN8xf4h" alt=""><br><br>The file will be renamed as <code>/myfiles/folderF/goodbye.txt</code> - so we are both moving and renaming the file:<br><br><img src="/files/hD2bXezN4xpo6Le0ocHe" alt=""></td><td><a href="/files/2vpVY6Q37YrYqTgeZirK">/files/2vpVY6Q37YrYqTgeZirK</a></td></tr></tbody></table>

#### The steps

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><p><strong>Connector settings for SFTP shape</strong></p><p>Our first <code>SFTP connector</code> step is configured as follows:</p><p><img src="/files/Y1gQLEbVI0Fl9TgWTx0w" alt="" data-size="original"></p><ul><li>Use the <code>SFTP GET user pass</code> endpoint.</li><li>Start looking for the file to rename from the <code>root</code>, which is defined as: <code>/myfiles/</code></li><li>Check the <code>path</code> for the file to rename, which is defined as: <code>folderE/hello.txt</code></li><li>Rename the file to the directory/name provided immediately after the <code>ftp command</code>. This is defined as: <code>rename:folderF/goodbye.txt</code></li></ul></td><td><a href="/files/oMb9sRQ3X0NcUlY4i8Mk">/files/oMb9sRQ3X0NcUlY4i8Mk</a></td></tr><tr><td><p><strong>Payload</strong> <strong>for SFTP shape</strong><br>When the process flow is run, the payload for our SFTP shape shows just a <code>1</code>:</p><p><img src="/files/phvQnMVVkyh1BdgGl47J" alt="" data-size="original"></p><p>A <code>1</code> indicates a successful response from your remote server. A <code>0</code> indicates an unsuccessful response.</p><p><br><br></p></td><td><a href="/files/J6YFhcQQMgUmK2sBQwdu">/files/J6YFhcQQMgUmK2sBQwdu</a></td></tr><tr><td><p><strong>Remote server outcome</strong></p><p>On our remote server, <code>hello.txt</code> is gone from <code>/myfiles/folderE</code>:<br><br><img src="/files/eqVRWrOjlT6w4pXj3MjX" alt=""></p><p><br>But now we have a file named, <code>goodbye.txt</code> in <code>/myfiles/folderF</code>:</p><p><img src="/files/ybyJDDfD93lOv89bcwCq" alt=""><br></p></td><td><a href="/files/CaDlvrcB9Vd1DmUVmK9d">/files/CaDlvrcB9Vd1DmUVmK9d</a></td></tr></tbody></table>
