Recommended Posts

I found this cool little script that will find your harddisk space.

import string
import win32api
import win32file

def PrintSpaceReport(drive):
sectorsPerCluster, bytesPerSector, numFreeClusters, totalNumClusters = win32file.GetDiskFreeSpace(drive + ":\\")
sectorsPerCluster = long(sectorsPerCluster)
bytesPerSector = long(bytesPerSector)
numFreeClusters = long(numFreeClusters)
totalNumClusters = long(totalNumClusters)

print
print "Drive: ", drive + ":\\"
print "FreeSpace: ", (numFreeClusters * sectorsPerCluster * bytesPerSector) / (1024 * 1024), "MB"
print "TotalSpace:", (totalNumClusters * sectorsPerCluster * bytesPerSector) / (1024 * 1024), "MB"
print "UsedSpace: ", ((totalNumClusters - numFreeClusters ) * sectorsPerCluster * bytesPerSector) / (1024 * 1024), "MB"

def main():
AvailableDrives = []
for i in string.split(win32api.GetLogicalDriveStrings(), '\000'):
if win32file.GetDriveType(i) == 3: # we only need fixed drives (no CD drives)
AvailableDrives.append(i[:-2])
DriveInfo = []

print "Drive free space report"

for drive in AvailableDrives:
PrintSpaceReport(drive)

if __name__ == '__main__':
main()

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...