How to rename a file on a local computer that has just been uploaded or downloaded?
If you need to rename a file 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: Rename the transferred file 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%"
rename /Y %1 %2Save 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-rename.bat
"%local_file%" "new_%local_file_name_only%.%local_file_name_ext%"
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 a combination of variables representing the path to the folder where the transferred file is already located, the prefix that will be added to the file name, and the current file extension.
Below are examples of different bat-files for renaming files:
Example #2: Renaming a file by adding the current date to the file name.
D:\my-bats\my-rename.bat
"%local_file%" "%local_file_name_only%-%c_yyyy%-%c_mm%-%c_dd%.%local_file_name_ext%"
Example #3: Renaming a file with a new .done extension
D:\my-bats\my-rename.bat
"%local_file%" "%local_file_name_only%.%local_file_name_ext%.done"
Note that you cannot specify a new drive or path for your destination file.
Next, we will look at how to copy, move, or unzip a recently downloaded file.
Need to rename a file on the SFTP server after transfer?


