From: Robert McGovern Date: 2002-11-18T08:47:47+09:00 Subject: Re: [FAQ] was RE: How do I get a '\'? > Q: How do I get a recursive list of all the files under a directory and > its subdirectories? Dir.entries only gets me the files in the specified > directory. Why isn't there a recursive version? > A: 'find' will probably do what you want. The code below fills 'dirs' > with directories and 'files' with filenames for a given directory > > require 'find' > dirs = [] > files = [] > Find.find(directory) {|f| > if FileTest.directory?(f) > dirs.push(f) > else > files.push(f) > end > } Using "Dir["#{directory}/**/**"].each" would work just as well as "Find.find(directory)". I don't know if its any better and it is a little harder to read / remember. However I find that "Find.find(directory)" in a bit unclear, it doesn't really tell you that it will find everything in a particular directory tree. To me it suggests that it will find anything that has "directory" in it. i.e. find . | grep directory (if you where using a *nix console) My 2p Rob -----------== Posted via Newsfeed.Com - Uncensored Usenet News ==---------- http://www.newsfeed.com The #1 Newsgroup Service in the World! -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----