Computing.Net > Forums > Programming > Batch Script Synchronize With FTP

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Script Synchronize With FTP

Reply to Message Icon

Name: meanMrKetchup
Date: February 6, 2009 at 13:25:11 Pacific
OS: Windows Server 2003
CPU/Ram: Lots
Product: Dell / Soylent
Subcategory: Batch
Comment:

I wrote this because I couldn't find anything better out there... but I learned a lot from these forums, especially M2. Here it is, a script to synch with the FTP. Are there any pointers or improvements anyone could suggest?

@ECHO off
setLocal EnableDelayedExpansion

:: Local directory
DIR /b [Loacal download direcotry] > FileList.txt

:: Set FTP configuration and get a list of files on the FTP
> FTP.do ECHO o [FTP Server]
>> FTP.do ECHO [username]
>> FTP.do ECHO [password]
>> FTP.do ECHO ls [add a directory here if you need to if youre not downloading from the root driectory] FTPList.txt
>> FTP.do ECHO bye

:: Run the FTP script
ftp -s:FTP.do

:: Set FTP configuration
> FTP.do ECHO o [FTP Server]
>> FTP.do ECHO [username]
>> FTP.do ECHO [password]
>> FTP.do ECHO cd [add a directory here if you need to if youre not downloading from the root driectory, if not, remove this line]
>> FTP.do ECHO lcd [Loacal download direcotry]
>> FTP.do ECHO prompt

:: Add files you don't already have
For /f "tokens=* delims=" %%a in (FTPList.txt) Do (
FindSTR /C:%%a FileList.txt
if errorlevel 1 (
ECHO get %%a >> FTP.do
) else (
ECHO %%a is already there
)
)

>> FTP.do ECHO bye

:: Run the FTP script
ftp -s:FTP.do

:: Delete files
del FTP.do
del FileList.txt
del FTPList.txt

CLS



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: February 6, 2009 at 14:26:18 Pacific
Reply:

At first reading, looks like you've done it very well. Nothing I can see that needs fixing.


=====================================
If at first you don't succeed, you're about average.

M2


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Script Synchronize With FTP

Batch script: Help with FOR file IO www.computing.net/answers/programming/batch-script-help-with-for-file-io/14915.html

Batch Script To FTP a file www.computing.net/answers/programming/batch-script-to-ftp-a-file/17008.html

batch script to upload to ftp www.computing.net/answers/programming/batch-script-to-upload-to-ftp/16987.html