Schedule an automatic FTP upload on Windows with WinSCP
Asked Answered
C

1

1

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

Childs answered 28/11, 2017 at 15:4 Comment(0)
A
4

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?

Album answered 28/11, 2017 at 15:27 Comment(1)
Thank you, this is just what I neededChilds

© 2022 - 2024 — McMap. All rights reserved.