batch - Downloading a file from multiple FTP's via excel/command prompt

24
2014-04
  • Ash

    I have a huge list of ip's which point to a text file I need to download. There is about 500 text files and the text filename is the same, data.txt.

    My initial thought was to use a macro to get the job done.

    Public Sub Example()
    
    Dim URL As String, LocalFilename As String
    
    URL = "ftp://user:[email protected]/data.txt"
    
    LocalFilename = "C:\Power Readings\Hall A\Company Name.txt"
    
    If URLDownloadToFile(0, URL, LocalFilename, 0, 0) = 0 Then
        'downloaded
        Stop
    End If
    
    End Sub
    

    This works neatly. But it only does the one file. My macro above allows a download of a single file from an ftp, renames it to how I want, and places it in a directory I want. However, I need this to repeat about 100 more times for different files. How can I do this? I don't mind changing the ip,filename manually in the script, but obviously, copy and pasting the script causes errors.

    My other idea, would be to have 3 columns in a spread sheet. Column A is the ip address of the file. B would be the name I wanted it to be renamed to when downloaded and C would be the directory to be downloaded to. Can this be done? So all I would need to do is populate the columns with data, hit a button and file is downloaded, renamed and placed in the right directory.

    One final option would be to have a batch file, which uses windows commant prompt to download all the files for me. But I don't know any of the commands. Any ideas?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    windows - Download a File in a Batch File
  • Cristian

    Possible Duplicate:
    Download a file via HTTP from a script in Windows

    I've never done any scripting on Windows but now I need to write a batch file that downloads a file off the Internet (amongst other things). If it was Linux I would use wget.

    Is there a built-in executable that will download a file to a given directory? This needs to run on Windows XP.


  • Related Answers
  • Peter Mortensen

    There is no builtin. But wget works just fine in batch files.