Synchronize files to an SFTP server

Solution 1:

What about making your WinSCP script easier to maintain?

I suppose all you need is to put one synchronize command per directory to your script. That does not sound too difficult to maintain.

I.e. your script (script.txt) would be like:

open sftp://user:[email protected] -hostkey="server_hostkey"

# one synchronize command per directory
synchronize remote C:\local_directory1 /home/user/remote_directory1
synchronize remote C:\local_directory2 /home/user/remote_directory2
...
synchronize remote C:\local_directoryN /home/user/remote_directoryN

exit

And you add a task to Windows Scheduler with command-line like:

"C:\Program Files\WinSCP\WinSCP.exe" "/script=path_to_script\script.txt" "/log=path_to_script\script.log"

Ideally also add the /ini=nul to command-line to isolate your script from environment.