Created
November 10, 2011 19:50
-
-
Save rafapolo/1355963 to your computer and use it in GitHub Desktop.
Exibe a soma do tamanho dos arquivos de uma pasta de torrents.
This file contains hidden or 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 'torrent_info.rb' | |
total_size = 0 | |
total_files = 0 | |
total_torrents = 0 | |
Dir.glob('files/*.torrent') do |f| | |
total_torrents += 1 | |
t = TorrentInfo.new(open(f).read) | |
size = t.size.to_f/1024/1024/1024 # resultado em giga | |
total_files += t.files_size | |
total_size += size | |
end | |
puts "Torrents: #{total_torrents}" | |
puts "Arquivos: #{total_files}" | |
printf('%.2f GBs', total_size) | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment