# determine size of a given folder in MBytes

import os

# pick a folder you have ...
folder = 'D:\\zz1'
folder_size = 0
for (path, dirs, files) in os.walk(folder):
  for file in files:
    filename = os.path.join(path, file)
    folder_size += os.path.getsize(filename)

print "Folder = %0.1f MB" % (folder_size/(1024*1024.0))

# determine size of a given folder in MBytes import os # pick a folder you have ...folder = 'D:\\zz1'folder_size = 0for (path, dirs, files) in os.walk(folder): for file in files: filename = os.path.join(path, file) folder_size += os.path.getsize(filename) print "Folder = %0.1f MB" % (folder_size/(1024*1024.0))

Is this really recursing through subfolders? I don't think so... it's only counting the root folder's files size, flat.

though it is working its not giving the actual size. calulated size is always less than actual size

yes sure, but 45 Mbytes difference isnt possible. Anyway thank y that y shared with us this code but better remove or modifty it!

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.