How to copy multiple files from an FTP site

I want to copy a few hundred files from an FTP site.  I have the following script.  I want to get all files of type *.txt and save them to a specific location (such as C:\Reports)

I can do it for one file at a time

...
get file1.txt C:\Reports\file1.txt
...

But how can I do it for all files of type *.txt?

Open [server.server.com]
[pwd]
[user]
binary
mget *.txt
bye

Open in new window

billelevAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gintu01Commented:
You pulling this more than once? If not, just use an ftp client such as Filezilla.
billelevAuthor Commented:
This did it for me
1:
2:
3:
4:
5:
6:

	

Open [server.server.com]
Open [server.server.com]
[pwd]
[user]
binary
lcd C:\Reports
prompt
mget *.txt
bye

Open in new window

Bill PrewIT / Software Engineering ConsultantCommented:
==> billelev

Yes, mget is the appropriate command for getting multiple files matching a filter mask.

FYI, a decent summary of the various commands here, feel free to ask about ones that don't make sense.

http://www.nsftools.com/tips/MSFTP.htm

as well as the offical Microsoft docs here:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ftp__subcommands.mspx?mfr=true

~bp
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Steve KnightIT ConsultancyCommented:
You have your answer there I imagine, and agreed mget is the best way...

.... but one other suggestion is to retrieve a directory listing and then process that and run a get for each.  Only really need to do that if you need to, say, retrieve a file then delete it or other similar processing etc. e.g.

ftp script doing a dir or ls command
capture the output, filter out irrelevant lines
use a for command to process this temporary file and make a new ftp script
use that ftp script to do the get and dele commands etc.

Steve

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
I think that might not be quite fair on the person who suggested using mget!

Steve
Steve KnightIT ConsultancyCommented:
Oh hang on that was you... sorry was my misread before, didn't realise you had posted own answer too.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.