Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: file size

  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    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) }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •