3 Replies Latest reply on Nov 3, 2010 11:42 AM by jbarrette-esristaff

    I can't make "findAndReplaceWorkspacePath" work

      Hello, I'm trying to repath hundreds of layer files but I have not been able to make "findAndReplaceWorkspacePath" work as intended, even using this basic example:

      Re-pointing a layer file from C to D drive:
      lyr = arcpy.mapping.Layer(r"C:\temp\index.lyr")
      workPath = lyr.workspacePath  # workPath points to "C:\temp\index.gdb"
      workPathNew = workPath.replace("C:\","D:\")
      lyr.findAndReplaceWorkspacePath(" ", workPathNew)
      lyr.save()  # result: index.lyr still points to C:\temp\index.gdb

      I tried,
      lyr.findAndReplaceWorkspacePath(workPath, workPathNew)
      lyr.save()  # result:  "Unexpected error"

      I tried to run the script in the Python window or Pythonwin but the results are the same.

      Thanks for any help I can get.

      BTW:  lyr.saveACopy("C:\temp\index_new.lyr", "9.3") does not work for me.  Here is the message I get:  "function takes exactly 1 argument (2 given)"