Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

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.

Thursday, 7 October 2010

Useful Windows Batch File Commands

This post has moved to my new website, if not redirected automaticaly please click here: https://anthonyblake.github.io/windows/cli/2010/07/10/useful-win-batch-commands.html 

The following code checks if a directory exists, if not it is created. It then moves a file into that directory.

This is ideal code to run before an ftp script as it will prevent a half written file being transmitted via FTP.

@echo off
if not exist "C:\Folder\Destination"
(

md "C:\Folder\Destination"
)
move "C:\Folder\Source\*.*"
"C:\Folder\Destination"

pause

The pause command lets you see the results of the script. Remove it if automated on a Windows Scheduled Task.