stephan@114: import arcpy, os
stephan@114: 
stephan@114: inputMXD = arcpy.GetParameterAsText(0)
stephan@114: 
stephan@114: newpath = r'C:\mxd-konverter\testdata-frida'
stephan@114: 
stephan@114: rootdir = inputMXD
stephan@114: 
stephan@114: for root, subFolders, files in os.walk(rootdir):
stephan@114:     for file in files:
stephan@114:         f = os.path.join(root, file)
stephan@114:         if os.path.isfile(f):
stephan@114:             basename, extension = os.path.splitext(f)
stephan@114:             if extension.lower() == ".mxd":
stephan@114:                 print "Bearbeitet Dokument %s" % f
stephan@114:                 mxd = arcpy.mapping.MapDocument(f)
stephan@114:                 #Report broken sources
stephan@114:                 if len(arcpy.mapping.ListBrokenDataSources(mxd)) > 0:
stephan@114:                     for brkLyr in arcpy.mapping.ListBrokenDataSources(mxd):
stephan@114:                         if brkLyr.supports("dataSource"):
stephan@114:                             oldpath =  brkLyr.dataSource
stephan@114:                             oldworkspace =  brkLyr.workspacePath
stephan@114:                             print "Old dataSource-Path %s, old workspacePath %s " % (oldpath, oldworkspace)
stephan@114:                             # Replace
stephan@114:                             brkLyr.findAndReplaceWorkspacePath(oldworkspace, newpath)
stephan@114:                             print "Corrected path: %s" % brkLyr.workspacePath
stephan@114:                             print "Corrected dataSource: %s" %brkLyr.dataSource
stephan@114:                             mxd.save()
stephan@114:                             print "Wrote file %s" % f
stephan@114:                             print arcpy.GetMessages()
stephan@114:                 else:
stephan@114:                     print "keine kaputten Layer gefunden"
stephan@114:             
stephan@114: del mxd