How to copy a file on a local computer that has just been uploaded or downloaded?

If you need to copy a file to another folder on the local computer 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 run any program, PowerShell script, or bat-file. As parameters, you can use built-in FTPGetter variables such as the %local_file% variable, which represents the full path of the transferred file on the local computer, date-related variables, and others.

Example #1: Copy the transferred file to another folder on the local computer.

Example #1: Copy the transferred file to another folder on the local computer.

To perform this operation, create a bat-file with the following content in any text editor.


SET "fullpath=%~dp2"
if not exist "%fullpath%" mkdir "%fullpath%"
copy /Y %1 %2

Save this file as my-copy.bat in any folder of your choice.

Important note! If you are using FTPGetter in Windows service mode, make sure that the account under which the service is running has full access to this folder.

In FTPGetter, this bat-file should be called as follows:


D:\my-bats\my-copy.bat

"%local_file%" "D:\path-to-copy-folder\"

Bat-file to copy file on local pc

How it works. After a successful file transfer, FTPGetter executes the my-copy.bat bat-file with two parameters. The first parameter is the %local_file% variable, which contains the full path of the recently transferred file (on the local computer). The second parameter is the path to the folder where the file should be copied.

Below are examples of different bat-files for copying files:

Example #2: Copying a file with a new name.

Add the current date to the file name:


D:\my-bats\my-copy.bat

"%local_file%" "D:\path-to-copy-folder\%local_file_name_only%_%c_yyyy%_%c_mm%_%c_dd%.%local_file_name_ext%"

Bat-file to copy file on local pc

Example #3: Copying a file with a new extension.

Add the .done extension


D:\my-bats\my-copy.bat

"%local_file%" "D:\path-to-copy-folder\%local_file_name%.done"
Bat-file to copy file on local pc

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


D:\my-bats\my-copy.bat

"%local_file%" "D:\path-to-copy-folder\%c_yyyy%-%c_mm%-%c_dd%\%local_file_name%"
Bat-file to copy file on local pc

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

Need to copy a file on the SFTP server after transfer?

Back on top