python os list all directories and subdirectories code example Example: how to get all folders on path in python os.walk(directory) [x[0] for x in os.walk(directory)]