Walk Through folders to find MXDs

Discussion created by rangermry on Jun 22, 2012
Latest reply on Jun 25, 2012 by jbarrette-esristaff
The below works great on MXDs nested directly in a folder, but how do you walk through all the files in folders in the folder?

import arcpy, os
folderPath = r"myfolderpathhere"
for filename in os.listdir(folderPath):
    fullpath = os.path.join(folderPath, filename)
    if os.path.isfile(fullpath):
        basename, extension = os.path.splitext(fullpath)
        if extension.lower() == ".mxd":
            mxd = arcpy.mapping.MapDocument(fullpath)
            mxd.findAndReplaceWorkspacePaths(r"mybeginningoldfoldeepath", r"mybeginningnewfolderpath")
del mxd