1

I want to copy a zip file from an FTP path to a local folder in my computer.

My client previously used coreftp.exe for that purpose. But now he ask us to use ftp.exe [default in windows machine, available at C:\Windows\System32\ftp.exe] for that purpose. The ftp is in the format :

ftp://username@ftpserver.address.com 

And want to download it to d:\sample\docs folder on my machine.

I want that in a batch file so that I can schedule it through windows task manager.

So could you please help me to write that command on the batch file.

Thanks a lot in advance.

Satej dubey
  • 41
  • 1
  • 4
  • Would you consider using a free tool that supports FTP as well - its called [SyncBack][1]. With it, you can set a scheduled task and connect to FTP with a nice graphic interface. Way better than using scripts if you ask me. [1]: http://www.2brightsparks.com/download-syncbackfree.html – peterkodermac May 13 '15 at 07:09
  • But my client specifically told me to use the default ftp.exe. So could you please help me with that. – Satej dubey May 13 '15 at 07:14
  • Okay, try out this [ftp via command prompt tutorial](http://www.howtogeek.com/howto/windows/how-to-automate-ftp-uploads-from-the-windows-command-line/) – peterkodermac May 13 '15 at 07:19
  • You can also take a look at this http://stackoverflow.com/questions/29700524/batch-file-to-download-a-file-with-name-that-starts-with-a-given-string-from-ftp/29711953#29711953 – Hackoo May 13 '15 at 07:51

1 Answers1

2

FTP.EXE is capable of executing script files. So you could just put this into your bat file:

@ECHO OFF
CD d:\sample\docs
FTP -v -i -s:C:\some\path\ftpscript.txt

And something like this into your ftpscript.txt:

open ftp://ftpserver.address.com
username
password
cd myfolder
get some_zip_file.zip
disconnect
bye

This will download some_zip_file.zip into the current directory (d:\sample\docs).

MichaelS
  • 5,941
  • 6
  • 31
  • 46
  • cd myfolder in the txt file is correct? or there i have 2 write CD d:\sample\docs.. becoz I have tried both but they r not working – Satej dubey May 13 '15 at 10:25
  • CD in the bat will determin where to save the downloaded file. CD in the txt is the command to change the diractory on the FTP server. In case the file is in the root directory of the FTP server you can just skip it. – MichaelS May 13 '15 at 10:28
  • If you have trouble with the FTP script you can just open CMD, type FTP and then enter the content of yout script file line by line. This way you can check which lines work for you and which don't. – MichaelS May 13 '15 at 10:29
  • Thanks. I have tried that. All success till I write put d:\sample\docs on the cmd. Pls note that I have full access over that folder.So any thoughts. – Satej dubey May 13 '15 at 11:22