Re: How to check for remaining hard drive space in Windows?



[... re getting free disk space ...]

Sick Monkey wrote:
Here you are:

>>> from win32com.client import GetObject
wmiObj = GetObject("winmgmts:\\\\MGW01641\\root\\cimv2")
diskinfo = wmiObj.ExecQuery("Select * from Win32_LogicalDisk")
for disk in diskinfo:
... print disk.Name, disk.FreeSpace
...
A: None
C: 16978259968
D: None


Well it's not often someone beats me to a WMI
solution :) Just to be different, you can also
look at the GetDiskFreeSpace function in the
win32api module of the pywin32 extensions.

The doc says: """
tuple = GetDiskFreeSpace(rootPath)

Retrieves information about the specified disk, including the amount of free space available.

Parameters

rootPath : string

Specifies the root directory of the disk to return information about. If rootPath is None, the method uses the root of the current directory.

Win32 API References

Search for GetDiskFreeSpace at msdn, google or google groups.

Return Value
The return value is a tuple of 4 integers, containing the number of sectors per cluster, the number of bytes per sector, the total number of free clusters on the disk and the total number of clusters on the disk.
If the function fails, an error is returned.
"""


TJG
.



Relevant Pages

  • Re: bad clusters != bad sectors? CHKDSK. How many is normal?
    ... I know nothing about bad sectors but I know how to search with google ... >>From the beginning, WinXP has always needed to do CHKDSK, every 2 weeks ... and it often finds bad clusters and errors in the MFT. ... >A disk check has been scheduled. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: it takes about 5 minutes to switch directories
    ... Keep your computer up to date with Windows Update and double ... option to Save to Disk or to Run. ... You have insufficient free disk space on your main hard drive. ... Again do it on both drives ignoring the "You do not ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Deleted file, but disk space not freed
    ... Reconciling space occupied by files plus free disk space to disk size ... Windows Explorer (and probably WinDirStat) counts the file size ... System Volume Information folder (primarily concerned with System ...
    (microsoft.public.windowsxp.general)
  • Re: How to check for remaining hard drive space in Windows?
    ... I got the code Sick Monkey provided ... for disk in diskinfo: ... sectors per cluster, the number of bytes per sector, the total number of ... free clusters on the disk and the total number of clusters on the disk. ...
    (comp.lang.python)
  • Re: Recd pop up notice re virtual memory
    ... With regards to doing the disk clean-up the last time ... A hard drive of 18.6 gb is unusually small as hard drives go today. ... Performance Settings, Advanced, Virtual Memory, Change and place the ... How large is your hard disk and how much free disk space. ...
    (microsoft.public.windowsxp.basics)