os.walk(directory) [x[0] for x in os.walk(directory)]
import os rootdir = 'path/to/dir' for file in os.listdir(rootdir): d = os.path.join(rootdir, file) if os.path.isdir(d): print(d)