From: Gavin Sinclair Date: 2002-08-29T14:17:37+09:00 Subject: Re: How to read files in all subdirectories? > Ruby experts: > > I know how to read each file in a subdirectory using the code below. My > question is: How can this code be modified so that the code will, in > addition, read each file in all subdirectories below "some_directory"? > > (I think what I want is a way to read all subdirectories "recursively".) Use the Find module, as per the following example. # Recurse into directories given on the command-line, printing the name of # each file, ignoring CVS directories, and adding / to directories. require "find" dirs = ARGV || ["."] Find.find(*dirs) do |path| Find.prune if File.basename(path) == "CVS" print path print "/" if File.stat(path).directory? print "\n" end > Thanks in advance! > > Kurt Euler > Gavin