win32: computing sizes of directories
aleaxit at yahoo.com
Fri Nov 10 20:56:26 CET 2000
"Les Schaffer" <godzilla at netmeg.net> wrote in message
news:87n1f7pyop.fsf at optonline.net...
> i was looking for a fast way to compute the size of a subdirectory in
> wondows (unix: 'du -s dirName' ) on specific directories in windows
> and i looked through the win32 extensions and couldnt find anything.
> but i am guessing its in there somewhere. anyone know?
Sure! For such tasks, I generally find that the object-models
of the "Scripting Runtime" and "Windows Scripting Host", as
accessed by COM, are handiest. For example:
fso = win32com.client.Dispatch("Scripting.FileSystemObject")
f = fso.GetFolder(path)
print "Folder %s takes, in all, %d bytes" % (path, f.size)
More information about the Python-list