Monday 11 October 2010

Creating an FTP Windows bat Script to Get/Put Automatically

First create a windows bat file conatining something like the following;

@echo off
REM THIS IS A COMMENT AND WILL NOT RUN
REM AUTO FTP SCRIPT
REM ANTHONY BLAKE 11/09/2010


REM myftpurl.com COULD ALSO BE THE IP OF THE FTP SITE
ftp -s:"c:\SCRIPTS\ftpAuto.txt" myftpurl.com

REM DONE!
exit

Then create your ftpAuto.txt;

myUserName
myPassword
bin
cd /DestFolder

put c:\OutboundFiles\UploadFile.csv
bye


The bat file calls the Windows FTP command and tells it to use the ftpAuto.txt script. The script changes the remote folder on the ftp site to "DestFolder" and puts the local file UploadFile.csv onto the server.

Setup a Windows Scheduled task to run at a desired interval which runs the bat file.

No comments:

Post a Comment

Thanks for the feedback!