import os,sys
from os.path import getsize
def lsdir(rootDir):
list_dirs = os.walk(rootDir)
size = 0L
for root,dirs,files in list_dirs:
for name in files:
size += getsize(os.path.join(root,name))
return size
def haveDir(rootDir):
list_dirs = os.walk(rootDir)
for root,dirs,files in list_dirs:
for dir in dirs:
dirSize = lsdir(os.path.join(root,dir))
dirSize = int(dirSize)
print dir,":",dirSize//1000
targetDir = sys.argv[1]
haveDir(targetDir)
|