I'm trying to do something quite simple but its not working. I want my python script to change all of the layers that point to the same datasource (a point shapefile) to another point shapefile. replaceDataSource seems to be the methods but when I run this:
for lyr in arcpy.mapping.ListLayers(mxd): #print lyr.name if lyr.dataSource == r"X:\filepath\folder\points.shp": print lyr.dataSource lyr.replaceDataSource(r"\\main.glb.corp.local\E-GB$\Home\AB\4\J022414\Documents\ArcGIS", 'SHAPEFILE_WORKSPACE', "ismage_template_P.shp") print "data replaced" mxd.saveACopy(mxd)
i get "Runtime error type 'exceptions.ValueError'>: Layer: Unexpected error" when I run this. It prints the data source but doesnt print "data replaced" so it looks like the problem is on the lyr.replacedatasource line
Has anyone had this problem before, or should I be using a different method?