Skip to content

Instantly share code, notes, and snippets.

@yangxing-star
Last active August 29, 2015 13:57
Show Gist options
  • Save yangxing-star/9595928 to your computer and use it in GitHub Desktop.
Save yangxing-star/9595928 to your computer and use it in GitHub Desktop.
输出文件路径和大小
photo_size = 0
dirs = Dir.glob('/home/star/Documents/shou65/public/uploads/*')
f = File.new('/home/star/public/photo.rb', 'w')
Dir.glob("#{dirs.first}/*/*").each do |i|
unless i.include?('_')
f.puts "#{i} -> #{f.size}"
photo_size += f.size
end
end
f.puts "total_size => #{photo_size}"
f.close
message_size = 0
dirs = Dir.glob('/home/star/Documents/shou65/public/uploads/*')
f = File.new('/home/star/public/message.rb', 'w')
Dir.glob("#{dirs.last}/*/*").each do |i|
unless i.include?('_')
unless i.include?('.mp3')
unless i.include?('.ogg')
f.puts "#{i} -> #{f.size}"
message_size += f.size
end
end
end
end
f.puts "total_size => #{message_size}"
f.close
user_size = 0
dirs=Dir.glob('/home/star/Documents/shou65/public/uploads/*')
f = File.new('/home/star/public/user.rb', 'w')
Dir.glob("#{dirs[1]}/*/*").each do |i|
unless i.include?('_')
#f.puts "#{i} -> #{f.size}"
user_size += f.size
end
end
f.puts "total_size => #{user_size}"
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment