User412387
User412387

Reputation: 89

Upload files generated in last one hour to FTP

I'm trying to upload latest files generated in one hour to a remote server. But the script I wrote is intelligent enough to gather only the latest file in directory and upload it to FTP. Any chance of set the variable type as array and upload the files in the array?

My FTP batch file:

FOR /F %%I IN ('DIR "abcdef*.bac" /B /O:D') DO SET latest_file=%%I

echo user domain/username> ftp.txt
echo password>> ftp.txt
echo cd remotepath>> ftp.txt
echo put %latest_file%>>ftp.txt
echo quit>> ftp.txt

ftp -n -s ftp.txt Servername>ftp_logs.txt

del ftp.txt

Upvotes: 1

Views: 243

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202167

It would be difficult to write this in a pure batch file code.

You better use some more powerful tool.

For example with WinSCP FTP client, it's trivial:

winscp.com /ini=nul /log=upload.log /command ^
    "open ftp://username:[email protected]/" ^
    "put -filemask=>1H C:\local\path\abcdef*.bac /remote/path/" ^
    "exit"

References:

(I'm the author of WinSCP)

Upvotes: 1

Related Questions