How to copy a file on the SFTP server that has just been uploaded or downloaded?

If you need to copy a file to another folder on the SFTP server after a successful upload or download operation, you should use a post-transfer trigger.

A post-transfer trigger is executed after a successful file transfer between the remote server and the local computer and allows you to execute any sequence of shell commands or a shell script. As parameters, you can use built-in FTPGetter variables such as the %remote_file% variable, which represents the full path of the transferred file on the SFTP server, date-related variables, and others.

Important note! To execute shell commands on the SFTP server, your account must have shell access rights. It is very easy to check whether you have these rights — you should be able to execute commands on the SFTP server in the terminal. If your account on the SFTP server does not have such rights, contact the SFTP server administrator to request this permission!

Example #1: Copy the transferred file to another folder on the SFTP server.

To perform this operation, add the following command to the shell script text field.


cp %remote_file% /path-to-copy-folder/


SFTP shell command to copy file on SFTP server

How it works. After a successful file transfer, FTPGetter executes the cp shell command with two parameters. The first parameter is the %remote_file% variable, which contains the full path of the recently transferred file (on the SFTP server). The second parameter is the path to the folder where the file should be copied.

Below are examples of different shell commands for copying files:

Example #2: Copying a file with a new name. Add the current date to the file name


cp %remote_file% /path-to-copy-folder/%remote_file_name_only%_%c_yyyy%_%c_mm%_%c_dd%.%remote_file_name_ext%

SFTP shell command to copy file on SFTP server

Example #3: Copying a file with a new extension. Add the .done extension


cp %remote_file% /path-to-copy-folder/%remote_file_name%.done

SFTP shell command to copy file on SFTP server

Example #4: Copying a file into a subfolder representing the current date


cp %remote_file% /path-to-copy-folder/%c_yyyy%-%c_mm%-%c_dd%/%remote_file_name%

SFTP shell command to copy file on SFTP server

Next, we will look at how to rename or move, unzip a recently transferred file on the SFTP server.

Need to copy a file on the local computer after transfer?

Back on top