shanenin Posted May 29, 2006 Report Share Posted May 29, 2006 I found this cool little script that will find your harddisk space. import stringimport win32apiimport win32filedef 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() Quote Link to post Share on other sites
Naming is hard Posted May 29, 2006 Report Share Posted May 29, 2006 Ohhh neat Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.