You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
787 B

from ctypes import windll
import os
#https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python
#u=RichieHindle
def get_drives():
uppercase = map(chr,range(ord('A'),ord('A')+26))
drives = []
bitmask = windll.kernel32.GetLogicalDrives()
for letter in uppercase:
if bitmask & 1:
drives.append(f'{letter}:\\')
bitmask >>= 1
return drives
def no_parents(paths):
paths = sorted(paths,key=len)
ret = []
paths
while len(paths) > 0:
el1 = paths[0]
ret.append(el1)
old_paths = paths[1:]
paths = []
for path in old_paths:
if not path.startswith(el1):
paths.append(path)
return ret