Skip to content

Instantly share code, notes, and snippets.

@Datise
Created November 3, 2014 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Datise/d4499584762e9bf309ca to your computer and use it in GitHub Desktop.
Save Datise/d4499584762e9bf309ca to your computer and use it in GitHub Desktop.
File input/output
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