Automate FTP Folder Synchronization with WinSCP
I've successfully completed such tasks using the awesome and ever so cool WinSCP product. I've provided you a sample Batch Script as well to help setup such a task for automation and thus providing you a rather full and complete answer to help satisfy your needs.
Essentially you will:
- Define the FTP connection within the WinSCP GUI
- Save the defined FTP connection and give it a name that indicates what it pertains
Use the FTP connection name in the script to open the connection for the FTP commands—see the Batch Script section



Batch Script
In the below batch script you will want to be sure these variables are set with the correct values: localdir, remotedir, winscplogin, and logfile so be sure those are set to point to the correct folders, WinSCP defined FTP connection, and log file—the rest should just work as-is.
@ECHO ON
:SetFileLogVariables
SET localdir=C:\dev\site123
SET remotedir="dev\site123"
SET logfile=C:\logs\FTP_dev_site123_sync.log
:SetPrgVariables
SET prgwinscp="C:\Program Files\WinSCP3\WinSCP.com"
SET winscplogin="DevSiteSync"
SET winscpfile=%temp%\~tmpWinSCPFTPSyncT_%~N0.txt
IF EXIST "%winscpfile%" DEL /Q /F "%winscpfile%"
:SetWinSCPSyncCommand
SET ftpcmd=synchronize remote "%localdir%\"
:ftpout
ECHO. >> %logfile%
ECHO *************************** FTP OUT *************************** >> %logfile%
ECHO Synchronizing files to %winscplogin% server on %date% at %time% >> %logfile%
ECHO option batch on >> %winscpfile%
ECHO option confirm off >> %winscpfile%
ECHO option transfer binary >> %winscpfile%
ECHO open %winscplogin% >> %winscpfile%
ECHO cd %remotedir% >> %winscpfile%
ECHO %ftpcmd% >> %winscpfile%
ECHO close >> %winscpfile%
ECHO exit >> %winscpfile%
ECHO %winscpfile% >> %logfile%
TYPE %winscpfile% >> %logfile%
ECHO ------------------------------------------- >> %logfile%
%prgwinscp% /script=%winscpfile% >> %logfile%
ECHO ------------------------------------------- >> %logfile%
IF EXIST "%winscpfile%" DEL /Q /F "%winscpfile%"
ECHO Transmission complete on %date% at %time% >> %logfile%
EXIT
WinSCP Connection Configuration Note
You will probably want to tell the WinSCP defined FTP connection to
NOT Remember the last directory used since the script will go to
the folder explicitly.
You complete this by highlighting the defined FTP connection name
within the WinSCP GUI and then select Edit | Advanced |
Directories | uncheck the box next to Remember the last directory used | OK | Save.

Syntax
synchronize local|remote|both [ <local directory> [ <remote directory> ] ]
Remarks
When the first parameter is local, changes from remote directory are
applied to local directory. When the first parameter is remote,
changes from the local directory are applied to the remote directory.
When the first parameter is both, both local and remote directories
can be modified.
When directories are not specified, current working directories are
synchronized.
Note: Overwrite confirmations are always off for the command.
Switches:

source
Further Resources