Batch Script Synchronize With FTP

February 6, 2009 at 13:25:11
Specs: Windows Server 2003, Lots
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


See More: Batch Script Synchronize With FTP

Report •


#1
February 6, 2009 at 14:26:18
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


Report •
Related Solutions


Ask Question