FileZilla Pro CLI: How to Create Dynamic Scripts

You may need to embed dynamic parameters in your scripts, like current date and time. You can use a
programming language of your choice to create scripts containing them.

See the example below. This is a Windows batch file that creates a script, and then launches FileZilla
Pro Command Line taking the script as parameter:

@ECHO OFF

REM Get the current date and time
FOR /f “tokens=2 delims==” %%a IN (wmic OS Get localdatetime /value ) DO ^

    SET “dt=%%a”

SET “YY=%dt:~2,2% & SET “YYYY=%dt:~0,4% & SET “MM=%dt:~4,2% & SET“DD=%dt:~6,2%
SET “HH=%dt:~8,2% & SET “Min=%dt:~10,2% & SET “Sec=%dt:~12,2%

SET NOW=%YYYY%%MM%%DD%_%HH%%Min%%Sec%
SET SCRIPT_NAME=dynamic-script-%NOW%

ECHO # Dynamic generated scrypt > %SCRIPT_NAME%
ECHO set engine.log.file fzcli-%NOW%.log >. %SCRIPT_NAME
ECHO connect ftpes://user:password@ftpserver.net >> %SCRIPT_NAME%
ECHO put ‐ ‐exists skip file file-%NOW% >> %SCRIPT_NAME%
ECHO ls >> %SCRIPT_NAME%
ECHO quit >> %SCRIPT_NAME%

“C:\Program Files\FileZilla Pro CLI\fzcli.exe” ‐ ‐script %SCRIPT_NAME%

The batch file first gets the current date and time and put in the variable NOW. It then creates a dynamic file name for the script based on the variable NOW. After that, it creates the dynamic script, adding several FileZilla Pro Command Line commands to the file. Note that some commands also use NOW: the log file name configuration and the name of the uploaded file.

Finally, it executes FileZilla Pro Command Line taking the script file created earlier.

Tags: ,