-
Notifications
You must be signed in to change notification settings - Fork 1
/
hdu
28 lines (24 loc) · 947 Bytes
/
hdu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! python
import os
import sys
#### Read the file size
def fileSize (file_name ):
if (os.path.exists(os.path.abspath(file_name)) and os.path.getsize(file_name)>0):
print "{} {} bytes".format(os.path.abspath(file_name),os.path.getsize(file_name))
return os.path.getsize(file_name)
else:
return 0
############# Main script
def main(dir_name):
total_size = 0
for root,dir,file_names in os.walk(dir_name):
for file_name in file_names:
file_wanted=os.path.join(root,file_name)
try:
total_size += fileSize(file_wanted)
except Exception,e:
print str(e)
#print "Total " + str(total_size) + " bytes"
return (str(total_size))
########## Main Starts here ...
print "Total " + main(sys.argv[1]) + " bytes "