Link to home
Start Free TrialLog in
Avatar of Sivasan
SivasanFlag for United States of America

asked on

Batch file to download a file from FTP server

Hi There,
I need to create a batch file to download a file in a particular folder from the FTp server to a folder on the local drive

Example  this is what I have
my ftp server name ftp.mydomain.com
user name     test
password       testp

so on the FTP server on a folder called Testfolder, I need to download all the files in this folder to the local C drive
in C:\temp   folder

I will appreciate if somebody can give me the line that will go on the batch file. I tried few never worked.
Avatar of SStory
SStory
Flag of United States of America image

It works best to use a script file with ftp from the batch file. That is two files, but much easier.

Your batch should look something like this
cd c:\Temp
ftp -n -s:C:\yourscript.src ipOfFTPServer

The script should contain something like:
user test testp
cd /TestFolder
binary
get somefilename
close
bye

Open in new window


Obviously you should change some things in the ftp line as needed, etc.
Avatar of Sivasan

ASKER

Hi SStory,
Thank you so much, it work, it downloads the file, but when I look at the size of the file it says 0 bytes, so I'm wondering if it completly downloaded the file. Is there a way I can make sure connection is open till file is downloaded completely?
thanks
Basic ftp commands can be found by using Google. Here are two examples:
http://www.nsftools.com/tips/MSFTP.htm
http://www.cs.colostate.edu/helpdocs/ftp.html

It sounds like it may be timing out on your before it finishes or there is some other problem.  I know of no other way to tell it to 'stay open'.  Mine just works when I do that.

I see a trace command that _MIGHT_ help you diagnose it.
Avatar of Sivasan

ASKER

Adding the trace command didn't bring up any trace, not sure if I'm using it right.
thanks
ASKER CERTIFIED SOLUTION
Avatar of SStory
SStory
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sivasan

ASKER

Thanks SStory, I will try few ftp solutions. Thanks for all your help