I am sure I am missing something simple (I usually just steal code snippets and try to string them together). I want to change the data source path in a bunch of layer files (I will add in a for… loop once I get this to work). This is a simple layer file, I will also need to update Group layer files
def main():
passif __name__ == '__main__':
main()
#Modules
import arcpy
#import string#Environments
arcpy.env.qualifiedFieldNames = False # Allow unqualified field names
arcpy.env.overwriteOutputlyr = arcpy.mapping.Layer(r"\\WC-HOMERB\Shared\GIS\Scratch\LayersForWilbur
\LegalParcelData.lyr")lyr.findAndReplaceWorkspacePaths(r"\\WC-HOMERB\Shared\GIS\GeoDatabase", r"E:
\GISData103\Data")lyr.save()
and I get this error message:
Help…
Solved! Go to Solution.
findAndReplaceWorkspacePath() not findAndReplaceWorkspacePaths()...
No 's' on Path
findAndReplaceWorkspacePath() not findAndReplaceWorkspacePaths()...
No 's' on Path
Yep, that did the trick.
Also, for anyone who looks this up in the future, it looks like the target workspace path needs to already exist.
(In my case there is no E:\ drive in our network – I was trying to preconfigure the files on my machine so I could simply copy and paste them to the other one. It is a production machine, so I try to refrain from mucking about on it very much)
Thanks,
Tycho
My above comment about the workspace path needing to exist was incorrect. All you need to do is set the validation flag to False. For example,
findAndReplaceWorkspacePath(r"\\WC-HOMERB\Shared\GIS\GeoDatabase", r"E:\GISData103\Data",False)