Go Back   CodingForums.com > :: Server side development > Ruby & Ruby On Rails

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-02-2007, 02:51 AM   PM User | #1
Macgoober
New to the CF scene

 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Macgoober is an unknown quantity at this point
Arrow file size

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?

thanks
Macgoober is offline   Reply With Quote
Old 08-03-2007, 08:12 PM   PM User | #2
ralph l mayo
Regular Coder

 
ralph l mayo's Avatar
 
Join Date: Nov 2005
Posts: 951
Thanks: 1
Thanked 31 Times in 29 Posts
ralph l mayo is on a distinguished road
Yeah, I don't think there's a way to get File.size to do all the work.

I'd use
Code:
Dir.new('/blah/dir').inject(0) { |sum, file| sum += File.size(file) }
ralph l mayo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:13 AM.


Advertisement
Log in to turn off these ads.