View Full Version : file size

08-02-2007, 03:51 AM
how would i go about going into a directory....and getting the size of all the files combined in that directory...

File.size("/blah/dir") doesnt accept the use of the wildcard *

and using . just makes it list the size of the DIRECTORY not the files it contains

any ideas?


ralph l mayo
08-03-2007, 09:12 PM
Yeah, I don't think there's a way to get File.size to do all the work.

I'd use

Dir.new('/blah/dir').inject(0) { |sum, file| sum += File.size(file) }