I want to iterate subdirectories within a directory and get all of the config.json
files at the root of each subdirectory. I am having trouble with stopping the walk function at the first subdirectory. An example of my folder structure is //abc001/e$/Intepub/wwwroot/Apps/Dev/Region-1
is the rootdir
while I want to get config.jsons out of folders like this //abc001/e$/Intepub/wwwroot/Apps/Dev/Region-1/website1/config.json
//abc001/e$/Intepub/wwwroot/Apps/Dev/Region-1/website2/config.json
//abc001/e$/Intepub/wwwroot/Apps/Dev/Region-1/website3/config.json
Here is the code that I have been working with; it returns all folders within the rootdir
and gives me an IOError
. How do I stop the iteration and resolve the IOError?
import os
rootdir = r'//abc001/e$/Intepub/wwwroot/Apps/Dev/Region-1'
for subdir, dirs, files in os.walk(rootdir):
for dir in dirs:
print dir