How to create a .BAT file to download a file from an HTTP \ ftp server?

How to create a .BAT file to download a file or folder from an FTP server? (and replace it with an existing file) (we have links like ftp://me: mypass@example.com /file.file (or http://example.com/file.file ) and an absolute link to the file, for example C:\Users\UserName\Some mixed English Adress\file.file ) (using only native windows (xp vista win7, etc.) BAT functions and files)

+6
windows batch-file ftp
source share
4 answers

Here is an example of how to automate the ftp.exe built-in tool:

The boot example, but the principle is the same (just use get instead of put ).

However, since these are just “piping commands” in ftp.exe, I recommend that you do not do this for production-quality batch files (without error handling, etc.), but use some kind of external tool instead. I gave this answer only because you explicitly asked for a solution that uses only the built-in Windows commands.

EDIT: Here's a concrete example:

 REM replace this with your user name and password REM make sure there is no space between the pwd and the >> echo user me > getftp.dat echo mypass>> getftp.dat echo binary >> getftp.dat REM replace this with the remote dir (or remove, if not required) echo cd remoteSubDir >> getftp.dat REM replace this with the local dir echo lcd C:\Users\UserName\SomeLocalSubDir >> getftp.dat REM replace this with the file name echo get file.file >> getftp.dat echo quit >> getftp.dat REM replace this with the server name ftp -n -s:getftp.dat example.com del getftp.dat 
+6
source

I previously used WGET in a batch file to accomplish this. http://www.gnu.org/software/wget/

+1
source

What FTP client software do you use? Is this a script? If so, create a script that loads the files and calls this script from your batch file.

I am doing this with WS_FTP.

+1
source

FTP with a command line built into most Windows operating systems is scriptable . You just need to create a text file with the commands that you would send if you ran it manually (one command on each line) and then executed it as follows:

 ftp -s:download.scr 
+1
source

All Articles