Reputation: 1
How can I download multiple folder from one server to another server via ftp connection. My main folder called "backup" have sub-folders called Folder A, Folder B and Folder C. My batch file is as 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 I run the above script, it show file not found. So, all what I have to do is I have to write script for each folder. It is work when I write it as 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 *
... and replace with FolderB and FolderC for another scripts.
it is possible to download multiple folders in single batch file? Thank in advance.
Upvotes: 0
Views: 4100
Reputation: 29369
You can first download the list of folders and then in a separate ftp session, iterate over the list.
Run this first ftp script that will download a list of folders
open myserver
myid
mypw
cd backup
mls * ls.txt
quit
and then dynamically build a second ftp script using the contents of ls.txt, something like this...
copy ftp.txt ftp2.txt
for /f "tokens=*" %%a in (ls.txt) do (
echo cd %%a >>ftp2.txt
echo mget * >>ftp2.txt
echo cd .. >>ftp2.txt
)
Upvotes: 1