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)