This handy little utility determines the size of a folder and it's subfolders in MBytes.
# 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.
yes sure, but 45 Mbytes difference isnt possible. Anyway thank y that y shared with us this code but better remove or modifty it!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.