This is an old revision of the document!
How do I automate file transfers?
WinSCP has supports scripting that you can use to automate many operation that it supports, including file transfers.
Commands
To automate operation, you need to find out commands necessary to implement it. For simple operations you need at least to:
- Set script to be performed non-interactively. For most automation scripts, you should use commands
option batch on
andoption confirm off
. - Open session. You can use
open
command (alternatively specify session on command line). - Perform operation. For uploads use
put
command, downloads useget
command. For other operations, see supported commands. - Exit scripting using
exit
command.
Script file
Assemble the commands into script file. You can name the script file as you like. See simple example and some useful scripts.
Use /script
command line option to pass the script to WinSCP. You can embed whole command line into Windows batch file (.bat
), such as:
@echo off winscp /console /script=myscript.txt
Using script
Now to make using script easier/automatic you can:
- Make shortcut to it on desktop. Either make shortcut to batch file (
.bat
) or enter full command line to shortcut itself. - Schedule automatic execution.
Notes
When connecting to particular host for the first time, you will be prompted to verify host key.