Schedule an automatic FTP upload on Windows with WinSCP

Issue

Let me preface this with a disclaimer, I have never executed scripts on the UI of WinSCP.

I have a program on our server that generates a text file that I want to be sent to our organization’s shared drive. While looking through the internet I came across a few solutions, such as the code below. (Credentials have been left out for obvious reasons)

option batch abort
option confirm off
open ftp://user:[email protected]
synchronize local U:\DO Unitization\Team Member Folders\xxxxxxxx
exit

This is then saved as a .txt (abc.txt)

Then executed manually as winscp.com /script=abc.txt

This is not what I want, seeing as thought the whole purpose was to automate this. Also, only one file actually needs to be sent, not everything in the directory. As I said above, my knowledge is lacking in this area so I apologize for any miscommunication.

Thank you,
Joshua Averbuch

Solution

For a start, see WinSCP guide to automating file transfers to FTP server.

A simple batch file (upload.bat) to upload a file to FTP server with WinSCP looks like:

winscp.com /log=c:\path\ftp.log /command ^
    "open ftp://user:[email protected]/" ^
    "put ""U:\DO Unitization\Team Member Folders\xxxxxxxx\file.txt"" ""/remote/path/""" ^
    "exit"

You can have the batch file generated by WinSCP GUI for you.


For scheduling, simply use the Windows Scheduler.
For details see another WinSCP guide to scheduling file transfers to FTP server.


Similarly for a download: How to schedule an automatic FTP download on Windows?

Answered By – Martin Prikryl

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published