FTP batch file download multi folders -


how can download multiple folder 1 server server via ftp connection. main folder called "backup" have sub-folders called folder a, folder b , folder c. batch file below.

@ftp -i -s:"%~f0"&goto:eof open myserver myid mypw hash bin  lcd d:\users\desktop\test    #cd smsbackup/  cd backup/ #my main folder location mget * 

when run above script, show file not found. so, have have write script each folder. work when write below.

@ftp -i -s:"%~f0"&goto:eof open myserver myid mypw hash bin  lcd d:\users\desktop\test    #cd smsbackup/  cd foldera/ #my main folder location mget * 

... , replace folderb , folderc scripts.

it possible download multiple folders in single batch file? thank in advance.

you can first download list of folders , in separate ftp session, iterate on list.

run first ftp script download list of folders

open myserver myid mypw cd backup mls * ls.txt quit 

and dynamically build second ftp script using contents of ls.txt, this...

copy ftp.txt ftp2.txt /f "tokens=*" %%a in (ls.txt) (   echo cd %%a >>ftp2.txt   echo mget * >>ftp2.txt   echo cd .. >>ftp2.txt )   

Comments