view contrib/python/FixWorkspacePaths.py @ 269:7c8ae43bc465 release-0.9

* HowTo-Release.txt: Added some more hints for releses. * doku/source/conf.py: Bumped version-number to 0.9 * website/development-de.htm4, website/development.htm4, website/download-de.htm4, website/download.htm4, website/header.m4: Updated links to version 0.9
author Stephan Holl <stephan.holl@intevation.de>
date Thu, 08 Sep 2011 17:13:31 +0200
parents 4dc2b9aa3c57
children
line wrap: on
line source
#
# Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de>
# 
# This file is part of MXD2map.
#
# This program is free software under the LGPL (>=v2.1)
# Read the file LICENCE.txt coming with the software for details
# or visit http://www.gnu.org/licenses/ if it does not exist.
#
# MXD2map has been developed on behalf of the
# Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
# by Intevation GmbH.
#
# Authors:
# Raimund Renkert <raimund.renkert@intevation.de>
# Bjoern Schilberg <bjoern.schilberg@intevation.de>
# Stephan Holl <stephan.holl@intevation.de>

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
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)