from ctypes import windll #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) first = True ret = [] while len(paths) > 0: el1 = old_paths[0] old_paths = paths[1:] paths = [] for path in old_paths: if not paths.startswith(el1): paths.insert(0,path) return ret