Schedule an automatic FTP upload on Windows with W

2020-03-30 06:09发布

问题:

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:pass@server
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

回答1:

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:password@example.com/" ^
    "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.