Question:
Use Command Prompt As FTP Client?
2012-09-26 17:28:23 UTC
As the title would suggest, I'm hopign to be able to use commant prompt to help me with a task. The end result would be running a batch file which would tell command prompt to login to an ftp, download a file, rename said file and then move on to another ftp. Repeat and rinse for about 400 more. I know I would have to input the ips and names manually in the batch file, but I don't know where to start. I tried opening command prompt and typing:

ftp user:pass@199.199.199.9 but that doesn't work. Any ideas on how to make this run and download this files for me and rename them?
Three answers:
Mr Ed
2012-09-26 17:41:03 UTC
This task is probably best suited for a custom-made program. If you have any kind of programming experience at all, it wouldn't take long to write... 20-30 minutes, probably. (Alas, I'm guessing you don't have such experience, or else you would have written it yourself.)



The program could read in from a text file all of the FTP sites you wish to visit (if there is more than one) and all of the names of the files. So yes, you would have to first set this up. But the program would then download the said named files, one after another, renaming them as it goes.



Few FTP clients out there now are going to have a command-line option. Most all that I know have a GUI. Also few have the ability for batch mode, in the manner you describe.



This is another reason to study a programming language, even BASIC. Wish such knowledge, you can write a program like this, to assist you in your task.
Robert
2012-09-26 17:44:09 UTC
What you want to put in your batch file as the main idea is:



%WINDIR%\system32\ftp -s:filename.txt user:pass@199.199.199.9



... where filename.txt contains your ftp commands (the ones you would do manually in ftp once logged in ... you deal with the host,username,password at the ftp command line*)

eg.

put filebeinguploaded.txt

get filebeingdownloaded.txt



* Others of interest maybe: "mget", "mput", "mdelete", "delete", "ascii", "binary", "prompt" (this one toggles whether it prompts on "mput" or "mget" or "mdelete"), "delete", "cd", "rename", "bye" (make sure you put this at end") etcetera. To get help on ftp go "ftp" at command prompt and type ? at ftp prompt.



..............



The Batch file supervisor needs IF logic maybe ... something like:



:top

IF EXIST %TEMP%\stopftp.now goto nogo



rem do your stuff here and if finished echo. > %TEMP%\stopftp.now

rem line below pauses for a bit (change 20 for longer)

%WINDIR%\system32\ping 127.0.0.1 -n 20 > nul

GOTO top



:nogo

exit
2012-09-27 09:53:12 UTC
If this is something you are going to do on a regular basis I suggest using Auto FTP Manager. Create a profile for each FTP and then click 'schedule' on each one. http://www.deskshare.com/ftp-client.aspx


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...