You have to walk the directory tree and sum each file's size.  Windows does 
this too - try your right-click properties on a large directory and see how 
long it
takes.  That's also what du does.  There are, however, some recipes that should 
make this fairly simple for you - try this:
 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/86554
 
 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tony Cappellini
Sent: Tuesday, April 22, 2008 2:03 PM
To: python-win32@python.org
Subject: [python-win32] Size of directory



When I right click on a directory with windows Explorer, a window is displayed 
showing

Size:
Size On Disk:
Contains:
Created:
Attributes:
(with the appropriate values for each entry)


How do I get the same information via Python ?

I've looked at os.stat but 

os.stat(r'C:\temp')[os.path.stat.ST_SIZE] 

only returns the size of a "plain file" :(


It's really a shame that windows doesn't have a built-in tool to show you a 
tree of subdirectories, and how much space is occupied by each subdirectory.

I guess I need to roll my own- once I know what the underlying call is to get 
the size of each directory



DISCLAIMER:
This e-mail, and any attachments thereto, is intended only for use by the 
addressee(s) named herein and
may contain legally privileged and/or confidential information. If you are not 
the intended recipient
of this e-mail, you are hereby notified that any dissemination, distribution or 
copying of this e-mail, and 
any attachments thereto, is strictly prohibited. If you have received this in 
error, please immediately notify 
me and permanently delete the original and any copy of any e-mail and any 
printout thereof. 
E-mail transmission cannot be guaranteed to be secure or error-free. The sender 
therefore does not accept 
liability for any errors or omissions in the contents of this message which 
arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Direct Edge ECN LLC may, at its discretion, monitor and review the content of 
all e-mail communications.

www.directedge.com
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to