From: Mark Thomas Date: 2009-04-14T20:45:03+09:00 Subject: Re: FTP - Multiple file downloads On Apr 14, 4:55 am, Idealone Ideally wrote: > I have written ftp code which will download a single file from the > Server using the below code: > > require 'rubygems' > require 'net/ftp' > require 'fileutils' > > URL = 'IP address' > username = 'test' > passwd = "test" > filename = "file1" > directory = '/home/test/' > localfile = 'C:\\Documents and Settings\\User1\\Desktop\\file1' > ftp=Net::FTP.new > ftp.connect(URL,21) > ftp.login(username,passwd) > ftp.chdir(directory) > ftp.getbinaryfile(filename,localfile) > ftp.close > > But what i am really looking for is: > 1) Download multiple files from a given directory. > 2) Download files by giving wild characters (eg: *.xls or *.txt) > > Please let me know if there is a better way or easier way to achieve > these tasks. Not all that familiar with the library, but I do recall there is a list method that accepts wildcards. Try something like this: files = ftp.list('*.xls') files.each do |filename| ftp.getbinaryfile(filename, filename) end -- Mark