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