Entry
How can I enumerate drives (local and network) in Python?
Jul 12th, 2000 00:36
unknown unknown, richard_chamberlain
On Win32 you can use:
import win32api,string
drives=win32api.GetLogicalDriveStrings()
drives=string.splitfields(drives,'\000')
print drives
GetLogicalDriveStrings returns a string with each drive null terminated
so you can use the string module to separate them into a list.
There is also a win32api.GetLogicalDrives() which returns a bitmask
where each bit represents a drive letter, so 1101 (or 13 in decimal)
would represent (going from right to left) a:\,c:\ and d:\.