Is there a way to return a list of all the subdirectories in the current directory in Python?
I know you can do this with files, but I need to get the list of direct
The easiest way:
from pathlib import Path from glob import glob current_dir = Path.cwd() all_sub_dir_paths = glob(str(current_dir) + '/*/') # returns list of sub directory paths all_sub_dir_names = [Path(sub_dir).name for sub_dir in all_sub_dir_paths]