Skip to content

Instantly share code, notes, and snippets.

@noiano
Created August 26, 2011 09:04
Show Gist options
  • Save noiano/1173018 to your computer and use it in GitHub Desktop.
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
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