<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic I can't make &amp;quot;findAndReplaceWorkspacePath&amp;quot; work in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395907#M4302</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Re-pointing a layer file from C to D drive:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;---------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr = arcpy.mapping.Layer(r"C:\temp\index.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;workPath = lyr.workspacePath&amp;nbsp; # workPath points to "C:\temp\index.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;workPathNew = workPath.replace("C:\","D:\")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.findAndReplaceWorkspacePath(" ", workPathNew)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.save()&amp;nbsp; # result: index.lyr still points to C:\temp\index.gdb&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.findAndReplaceWorkspacePath(workPath, workPathNew)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.save()&amp;nbsp; # result:&amp;nbsp; "Unexpected error"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to run the script in the Python window or Pythonwin but the results are the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help I can get.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW:&amp;nbsp; lyr.saveACopy("C:\temp\index_new.lyr", "9.3") does not work for me.&amp;nbsp; Here is the message I get:&amp;nbsp; "function takes exactly 1 argument (2 given)"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Oct 2010 20:11:31 GMT</pubDate>
    <dc:creator>EricAubert</dc:creator>
    <dc:date>2010-10-21T20:11:31Z</dc:date>
    <item>
      <title>I can't make "findAndReplaceWorkspacePath" work</title>
      <link>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395907#M4302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Re-pointing a layer file from C to D drive:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;---------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr = arcpy.mapping.Layer(r"C:\temp\index.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;workPath = lyr.workspacePath&amp;nbsp; # workPath points to "C:\temp\index.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;workPathNew = workPath.replace("C:\","D:\")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.findAndReplaceWorkspacePath(" ", workPathNew)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.save()&amp;nbsp; # result: index.lyr still points to C:\temp\index.gdb&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.findAndReplaceWorkspacePath(workPath, workPathNew)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.save()&amp;nbsp; # result:&amp;nbsp; "Unexpected error"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to run the script in the Python window or Pythonwin but the results are the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help I can get.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW:&amp;nbsp; lyr.saveACopy("C:\temp\index_new.lyr", "9.3") does not work for me.&amp;nbsp; Here is the message I get:&amp;nbsp; "function takes exactly 1 argument (2 given)"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 20:11:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395907#M4302</guid>
      <dc:creator>EricAubert</dc:creator>
      <dc:date>2010-10-21T20:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: I can't make "findAndReplaceWorkspacePath" work</title>
      <link>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395908#M4303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Eric,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure if the problem you are having is with your .replace statement.&amp;nbsp; You are not using the raw (r) format, the back slashes may be causing a problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr = arcpy.mapping.Layer(r"C:\temp\index.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.findAndReplaceWorkspacePath(r"C:\", r"D:\")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.save()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Oct 2010 15:09:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395908#M4303</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2010-10-25T15:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: I can't make "findAndReplaceWorkspacePath" work</title>
      <link>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395909#M4304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jeff, thanks for the reply.&amp;nbsp; You are correct, I should have used the "raw" format in my example, my fault.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After carefully reading the documentation, I realized that by default the "validate" is set to True.&amp;nbsp; In my case ,the database that I was trying to re-point the layer file did not exist yet.&amp;nbsp; This syntax now works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.findAndReplaceWorkspacePath("", workPathNew, False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.findAndReplaceWorkspacePath(workPath, workPathNew, False)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Eric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Oct 2010 15:56:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395909#M4304</guid>
      <dc:creator>EricAubert</dc:creator>
      <dc:date>2010-10-25T15:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: I can't make "findAndReplaceWorkspacePath" work</title>
      <link>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395910#M4305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Eric,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on the testing we've done together, it appears your issue is resolved with SP1.&amp;nbsp; Several issues have been addressed that are specific to change SDE data sources.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Nov 2010 18:42:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/i-can-t-make-quot-findandreplaceworkspacepath-quot/m-p/395910#M4305</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2010-11-03T18:42:49Z</dc:date>
    </item>
  </channel>
</rss>

