How to get a directory size with win32 api ?

Dale Strickland-Clark dale at riverhall.NOSPAMco.uk
Mon Sep 17 21:30:40 CEST 2001


francois-regis.chalaoux at sanofi-synthelabo.com (copter24) wrote:

>Hi,
>
>How to get a directory size with win32 api ?
>Any code exemple ?
>
>FR

If you mean in terms of total kbytes occuplied, I don't think you can.

You can, however, use the FileSystemObject COM object which is part of
VBScript/JScript but I think can be used anywhere COM is accessible.

>>> from win32com.client import Dispatch
>>> fso = Dispatch("Scripting.FileSystemObject")
>>> fldr = fso.GetFolder("C:\\WINNT")
>>> fldr.Size
892129383
>>> 

If you mean in terms of number of files, os.listdir() will probably do
the job.
--
Dale Strickland-Clark
Riverhall Systems Ltd



More information about the Python-list mailing list