DOS How To

FTP connection using BATCH file

I really love DOS commands. They are so powerful and yet simple (most of the time). Few days back I was required to create a script to download files from FTP site to local folder, and this has to be done at scheduled time. I decided to use my all time favorite script language to do this job …. yes a batch file with dos commands, honestly it is not like that I am partial to batch file and dos commands (hmm, may be a little bit)  but I personally find PowerShell a bit cryptic. And thus I try to avoid it’s use (plus our production servers don’t have PowerShell installed)

Ok, aside from my reasons for not using PowerShell, I was able to create a tiny script for my task. Script is very simple, it opens up a connection to ftp site. Provides user id and password. Selects FTP download directory (in this demo script it also selects file). And download it to local folder. And this is a simple TEXT file.

cd \softlib
lcd D:\Temp\
prompt n

But to run a FTP script you will need to also create a batch file which initiates this ftp script on FTP command. So I created another batch file to execute this FTP script.

rem @echo off
ftp -s:"D:\Temp\ftp_test.txt"  <—name of txt file (above)

And you are all set. This script will download “README.TXT” file off the MSFT FTP server into D:\Temp folder. If you are curious you can browse MSFT FTP site, which is same as

That’s it for now.

It’s Just A Thought … Peace

Gaurang Sign

By Gaurang

First thing I would like to write is a question .... Why the hack people write their bio in 3rd person ?

I am Gaurang. I work as DBA / DEV for local company in CT. When I am not working, I am either reading other blogs n news OR "researching" / "experimenting" about things that I can do at home / at work OR tinkering with some new hardware/software OR playing games on my desktop.

If you ever wanted to contact me, I can be reached by

Leave a Reply

Your email address will not be published. Required fields are marked *