AnsweredAssumed Answered

Use partial paths in findAndReplaceWorkspacePaths

Question asked by monzay on Aug 28, 2014
Latest reply on Aug 28, 2014 by monzay

I want to partially change the path for layers in an mxd from a letter drive to a UNC path.


The help page for updating and fixing datasources with arcpy states "...allows you to substitute an entire or partial string for a layer..." but I cannot figure out how to partially replace a path. I have an mxd with one layer that points to W:\Data\City\Planimetric\xyz_planimetric_data_2011.mdb


This doesn't change the path.


import arcpy
mxd = arcpy.mapping.MapDocument(r'C:\GIS\test\AppServerConnections.mxd')
for lyr in arcpy.mapping.ListLayers(mxd):
    wp = lyr.workspacePath
    if 'W:' in wp:
        nwp = r"\\\gisserver2" + wp[2:]

del mxd


if I substitute add a print statement here


if 'W:' in wp:
   nwp = r"\\gisserver2" + wp[2:]
   print nwp


it prints as I would expect: \\gisserver2\Data\City\Planimetric\xyz_planimetric_data_2011.mdb


What am I missing?