SFTP Move / Rename
SFTP Move / Rename
Section titled “SFTP Move / Rename”Type: sftp-move · Package: SFTP Activities v1.1.0 · Output: string
Moves or renames a file on the SFTP server. Widely used to archive what was processed: after downloading a file, move it to a /processed folder on the server so it is not picked up again.
How it works
Section titled “How it works”Renames sourcePath to destinationPath (both remote paths, with the file name). If both are in the same folder with different names, it is a rename; if the folder changes, a move. The operation happens on the server, without transferring the content.
- The destination folder must exist.
- If a file already exists at
destinationPath, most servers reject the change: delete or rename the existing one first, or use a unique name (for example with the date).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
sourcePath | string | — | Remote source path. |
destinationPath | string | — | Remote destination path, with the file name. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanSftpSession | — | Session from SFTP Connect. Inherited inside a body. |
Output
Section titled “Output”Returns a string with the new remote path of the file (the same value as destinationPath). Since version 1.1.0 the Designer offers it as an output.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'sourcePath' is required. / 'destinationPath' is required. | The parameter is missing or the expression returned null. |
'session' must be a ZoanSftpSession. | The activity is outside the SFTP Connect body and received no session. |
| Server error: file not found | sourcePath does not exist (maybe it was already moved in a previous run). Check it with SFTP Exists. |
| Server error when renaming | The destination already exists, its folder does not exist, or the user has no write permission. |
Example
Section titled “Example”Archive on the server after downloading, with the date in the name to avoid clashing with earlier files:
SFTP Download remotePath = "/outbound/data.csv" localPath = "C:/downloads/data.csv"SFTP Move / Rename sourcePath = "/outbound/data.csv" destinationPath = "/outbound/processed/data_" + now().ToString("yyyyMMdd-HHmmss") + ".csv"Related activities
Section titled “Related activities”- SFTP Delete — delete instead of archiving.
- SFTP Create Directory — create the destination folder.