Created
November 3, 2014 19:23
-
-
Save Datise/d4499584762e9bf309ca to your computer and use it in GitHub Desktop.
File input/output
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
require 'rubygems' | |
require 'rest-client' | |
require 'open-uri' | |
DIRNAME = "vagrant" | |
hash = Dir.glob('../../vagrant/*/**').inject({}) do |hash, fname| | |
ext = File.basename(fname).split('.')[-1].to_s.downcase | |
hash[ext] ||= [ 0,0] | |
hash[ext][0] += 1 | |
hash[ext][1] += File.size(fname) | |
hash | |
end | |
File.open("file-analysis.txt", 'w') do |f| | |
hash.each do |arr| | |
txt = arr.flatten.join("\t") | |
f.puts txt | |
puts txt | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment