Created
August 26, 2011 09:04
-
-
Save noiano/1173018 to your computer and use it in GitHub Desktop.
Displays the sum of the sizes of the files whose paths are read from an input file
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
import os | |
import sys | |
#definisco funzione per human readable size | |
def sizeof_fmt(num): | |
for x in ['bytes','KB','MB','GB','TB']: | |
if num < 1024.0: | |
return "%3.1f%s" % (num, x) | |
num /= 1024.0 | |
grand_total = 0 | |
file_with_sizes = open(sys.argv[1]) | |
for line in file_with_sizes: | |
curr_file_size=os.path.getsize( line.strip() ) | |
grand_total += curr_file_size | |
print "Total is " + str( sizeof_fmt(grand_total) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment