[python-win32] Size of directory
Larry Bates
larry.bates at websafe.com
Tue Apr 22 20:10:04 CEST 2008
Tony Cappellini wrote:
>
> 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
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
You have to walk the directory and accumulate the size. Even Explorer
does that (you can see if you do it on a really large directory).
-Larry
More information about the python-win32
mailing list