From: "Sandor Szücs" Date: 2008-04-13T00:01:59+09:00 Subject: Re: listing folder contents Hi Eoghan, On 08.03.2008, at 17:13, eoghan wrote: > Im listing the contents of a folder using this: > Find.find('/Volumes/MYBOOK/stuff/') do |f| p f end > This is fine, but im seeing hidden files are with ._ prefix. > Is there any easy way to exclude this? If you just don't want '._' prefix then match the File.basename with regex and do an if. Find.find('/Volumes/MYBOOK/stuff/') do |f| puts(f) if not File.basename(f).match(/^\._/) end Find.find(`pwd`.chomp) do |f| puts(f) if not f.match(/^\._/) end If you don't want to see all hidden files you can use Rake::FileList instead of using Find.find. irb> Rake::FileList['**/*'] => ["bfs_listing.rb", "bla", "bla/bla", "bla/bla/bla", "bla/bla/bla/ bla", "bla/bla/bla/bla/fasel2", "bla/fasel", "test1"] Here my example dir tested with your find irb> Find.find(".") do |f| p f end "." "./test1" "./bla" "./bla/fasel" "./bla/bla" "./bla/bla/bla" "./bla/bla/bla/bla" "./bla/bla/bla/bla/fasel2" "./bla/bla/bla/bla/._nein" "./bla/bla/bla/._nein" "./bla/bla/._nein" "./bla/._nein" "./bfs_listing.rb" "./.test" "./._nein" => nil > The folder contains sub folders alphabetised, as in a, b, c, d etc > another thing; when i print this i get: > "/Volumes/MYBOOK/stuff/a/file.stuff" > how could i just print > /a/file.stuff? The behaviour of Rake::FileList is that what I think you want, but you can implement your own tree traverse if you want. hth. sz --