import os def get_all(path): all_dirs = [] for root, dirs, files in os.walk(path): all_dirs.extend(dir for dir in dirs if os.path.isdir(os.path.join(root, dir))) all_dirs = all_dirs[1:] return all_dirs