Space left on device

S

sir_alex

Is there any function to see how much space is left on a device (such
as a usb key)? I'm trying to fill in an mp3 reader in a little script,
and this information could be very useful! Thanks!
 
R

rbt

sir_alex said:
Is there any function to see how much space is left on a device (such
as a usb key)? I'm trying to fill in an mp3 reader in a little script,
and this information could be very useful! Thanks!

On windows with the win32 extensions, you might try this:

# Get hard drive info from Windows.
drive = win32api.GetDiskFreeSpace('c:')
print drive[0], "sectors per cluster."
print drive[1], "bytes per sector."
print drive[2], "free clusters."
print drive[3], "total clusters."

You could use wmi to discover where the device has been mounted:
for item in c.Win32_DiskDrive():
print item

instance of Win32_DiskDrive
{
BytesPerSector = 512;
Capabilities = {3, 4, 7};
Caption = "M-SysT5 Dell Memory Key USB Device";
ConfigManagerErrorCode = 0;
ConfigManagerUserConfig = FALSE;
CreationClassName = "Win32_DiskDrive";
Description = "Disk drive";
DeviceID = "\\\\.\\PHYSICALDRIVE1";
Index = 1;
InterfaceType = "USB";
Manufacturer = "(Standard disk drives)";
MediaLoaded = TRUE;
MediaType = "Removable media other than\tfloppy";
Model = "M-SysT5 Dell Memory Key USB Device";
Name = "\\\\.\\PHYSICALDRIVE1";
Partitions = 1;
PNPDeviceID =
"USBSTOR\\DISK&VEN_M-SYST5&PROD_DELL_MEMORY_KEY&REV_5.00\\09809350C300C9D7&0";
SectorsPerTrack = 63;
Signature = 2865277640;
Size = "254983680";
Status = "OK";
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top