1

I want to get one or many files from a source ftp site. I only want to get the files that have a constant prefix ("ORDER"). I will later import these files into my db, but for right now, I just want to copy these specified files to my local directory ("c:\Destination").

I have tried this...

    open ftp.[address]
    [username]
    [password]
    cd \SubFolder
    for %%I in (ORDER*.txt) do copy %%I c:\Destination\
    quit

But nothing apparently happens(??). I am able to hardcode for a single file with a static name. but using the variable for multiple files is not working for me. I have used "copy", "xcopy" and "get" in the "do" command, but none appear to work.

Thanks in advance.

kevin
  • 45
  • 1
  • 5
  • 1
    You seem to mix up an `ftp` script and a batch file, but these are separate things... – aschipfl Apr 02 '19 at 21:26
  • Use `mget` command as in `order*`. Make sure `glob` is on. – Noodles Apr 02 '19 at 22:52
  • @aschipfi I save the file as a .bat, so I figured it was a batch file (I am clearly a novice in command line). I use similar code elsewhere to pick up statically named files in other FTP sites, so I used that as a starting point. But these files will be dynamically named with the "ORDER" prefix. – kevin Apr 02 '19 at 23:05
  • @Noodles I tried "mget" in place of "copy" in my above code and still no luck. I played with the glob setting as well, and it looks like it is "on" by default. – kevin Apr 02 '19 at 23:07
  • It is a text file with FTP commands. Not a batch file. You can call it anything you want. So `ftp -A -i speedtest.tele2.net` then `mget *KB.zip`. Unix servers are case sensitive. Your firewall may block standard FTP. Use PASV mode which Windows' FTP can't do. See `ftp /?`. – Noodles Apr 02 '19 at 23:27
  • 1
    See [Batch file to download a file with name that starts with a given string from FTP](https://stackoverflow.com/q/29700524/850848#29701443). – Martin Prikryl Apr 03 '19 at 06:05

0 Answers0