This is a quick example of how to automate a FTP task with a batch file. WinSCP allows you to utilize a script file with your connection details and commands, which makes things very easy.

Save the following details into “myscript.txt”:

# Answer all prompts negatively so the script
#does not stall on error
option batch on
# Disable overwrite confirmations
option confirm off
# Connect using a password
open ftp://myftpusername:mypassword@
# Upload files
put C:\mydirectory

Make sure to update these values appropriately:
myftpusername = FTP username
mypassword = FTP user’s password = IP or hostname of machine you are connecting to
C:\mydirectory = directory you wish to copy to the home directory of your FTP user

Then the following can be placed in a .bat file to execute the upload above:

C:\Program Files\WinSCP\winscp.exe /console /script=myscript.txt

Note you may need to update the path to the WinSCP executable or the myscript.txt file depending on your installation.

One Response to “Command line FTP with WinSCP”

  • Josh says:

    How do I update the values of the username and password? I’m trying to completely automate the process for someone else to send me files, and I don’t want them to have to remember their username and password. I can’t seem to get a script to enter those without prompting.

Leave a Reply