From: Robert Klemme Date: 2007-11-10T02:45:25+09:00 Subject: Re: Best way to test if a directory is empty 2007/11/9, Peter Marks : > I see this question was asked a while back > (http://www.ruby-forum.com/topic/84762), but I'm having trouble > implementing any of the solutions. I have tried: > > if Dir["#{RAILS_ROOT}/documents/"].empty? You need the star here as well - as you probably know by now. > if catch('empty'){Dir.glob("#{RAILS_ROOT}/documents/"){throw 'empty'}} I guess that should rather read unless catch('non_empty'){Dir.glob("#{RAILS_ROOT}/documents/*"){throw 'non_empty'}} Or am I missing something? > if Dir.entries("#{RAILS_ROOT}/documents/") == [] (see above) > , but none seem to work for me. Cheers robert -- use.inject do |as, often| as.you_can - without end