for root, dirs, files in os.walk(rootFolderPath): for filename in files: doSomethingWithFile(os.path.join(root, filename)) for dirname in dirs: doSomewthingWithDir(os.path.join(root, dirname))