Mercurial > mxd2map
view contrib/python/FixWorkspacePaths.py @ 195:123ebb293f3a
* website/.htaccess,
website/buildhtml.mk,
website/development-de.htm4,
website/download-de.htm4,
website/index-de.htm4,
website/switch.php: more contetn to the website, added
htaccess-switch to support the german-version only atm.
author | Stephan Holl <stephan.holl@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 17:02:50 +0200 |
parents | 93699e8f2d1f |
children | 4dc2b9aa3c57 |
line wrap: on
line source
import arcpy, os inputMXD = arcpy.GetParameterAsText(0) newpath = r'C:\mxd-konverter\testdata-frida' rootdir = inputMXD for root, subFolders, files in os.walk(rootdir): for file in files: f = os.path.join(root, file) if os.path.isfile(f): basename, extension = os.path.splitext(f) if extension.lower() == ".mxd": print "Bearbeitet Dokument %s" % f mxd = arcpy.mapping.MapDocument(f) #Report broken sources if len(arcpy.mapping.ListBrokenDataSources(mxd)) > 0: for brkLyr in arcpy.mapping.ListBrokenDataSources(mxd): if brkLyr.supports("dataSource"): oldpath = brkLyr.dataSource oldworkspace = brkLyr.workspacePath print "Old dataSource-Path %s, old workspacePath %s " % (oldpath, oldworkspace) # Replace brkLyr.findAndReplaceWorkspacePath(oldworkspace, newpath) print "Corrected path: %s" % brkLyr.workspacePath print "Corrected dataSource: %s" %brkLyr.dataSource mxd.save() print "Wrote file %s" % f print arcpy.GetMessages() else: print "keine kaputten Layer gefunden" del mxd