Created
September 1, 2012 10:31
-
-
Save danielpclark/3569117 to your computer and use it in GitHub Desktop.
count the size of all files in the directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
ttlsize = 0.0 | |
curdir = "" | |
if !!ARGV[0] | |
curdir = ARGV[0] + "/*" | |
else | |
curdir = "*" | |
end | |
Dir[curdir].each do |x| | |
ttlsize += (File.stat(x).size/1024.to_f).to_s[/.*\.../].to_f | |
end | |
puts ttlsize.to_s << " MB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment