<?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 Re: Problems with arcpy findAndReplaceWorkspacePath? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000960#M59026</link>
    <description>&lt;P&gt;You are using arcmap 10.4.... there are lots of bugs noted on the tech support site, that you may want to look at&amp;nbsp; for example&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDA5Njc3OQ==" target="_self"&gt;Bug BUG-000096779&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/technical-article/000022907" target="_self"&gt;Problem: Attempts to find and replace multiple data sources from enterprise geodatabase connections using Python fail&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but there are more&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/Search-Results#search?q=findAndReplaceWorkspacePath" target="_self"&gt;findAndReplaceWorkspacePath issues ... sort newest to oldest&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 23:42:33 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2020-11-12T23:42:33Z</dc:date>
    <item>
      <title>Problems with arcpy findAndReplaceWorkspacePath?</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000562#M59016</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I can't find and replace a workspace path with the following script:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# -*- coding: cp1252 -*-
import arcpy, os

arcpy.env.overwriteOutput = True

mxd=arcpy.mapping.MapDocument(r"C:\temp_replaceDatasource\Detail.mxd")

class ReplaceDataSource(object):

    def __init__(self):

        self.mxd = mxd
        
    def DataSourcesReplace(self):
        
        for lyr in arcpy.mapping.ListLayers(self.mxd, ""):
            
            if lyr.isServiceLayer == 1:

                print lyr.name + " is a WMS Layer"      

            else:
                
                print lyr.name + " X " + lyr.dataSource

                newDataSource = lyr.dataSource.replace("R:\\", "\\\\{}\\{}\\".format("Client", "R$"))
                
                print newDataSource

                lyr.findAndReplaceWorkspacePath(lyr.dataSource, newDataSource)

                print lyr.dataSource
            
        mxd.saveACopy(r"C:\temp_replaceDatasource\Detail_WIBAS.mxd")
       
                         
if __name__ == '__main__':

    MyClass = ReplaceDataSource()
    MyClass.DataSourcesReplace()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The print statement looks ok but the path is not replaced - nothing happens with the path? Any ideas why?&lt;/P&gt;&lt;P&gt;output of the print statement&lt;/P&gt;&lt;P&gt;Maßnahmenflaeche X R:\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data\Massnahme&lt;BR /&gt;\\Client\R$\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data\Massnahme&lt;BR /&gt;R:\SG-A\Karto\Bierer2020\Wiedemann_Erlen_Metten_Gründelbachniederung_Auftragskarte\Bearbeitung.gdb\data\Massnahme&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 07:26:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000562#M59016</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2020-11-12T07:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with arcpy findAndReplaceWorkspacePath?</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000603#M59018</link>
      <description>&lt;P&gt;Maybe lyr.save()&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 10:41:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000603#M59018</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-12T10:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with arcpy findAndReplaceWorkspacePath?</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000610#M59020</link>
      <description>&lt;P&gt;Thank you David,&lt;/P&gt;&lt;P&gt;unfortunately I get an error message if I insert lyr.save() after the findAndReplace ... :&lt;/P&gt;&lt;P&gt;line 35, in DataSourcesReplace&lt;BR /&gt;lyr.save()&lt;BR /&gt;File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\utils.py", line 182, in fn_&lt;BR /&gt;return fn(*args, **kw)&lt;BR /&gt;File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\arcobjects\mixins.py", line 416, in save&lt;BR /&gt;assert hasattr(self, '_lyr'), gp.getIDMessage(89003, "No filename set.")&lt;BR /&gt;AssertionError: No filename set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 11:29:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000610#M59020</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2020-11-12T11:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Problems with arcpy findAndReplaceWorkspacePath?</title>
      <link>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000960#M59026</link>
      <description>&lt;P&gt;You are using arcmap 10.4.... there are lots of bugs noted on the tech support site, that you may want to look at&amp;nbsp; for example&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDA5Njc3OQ==" target="_self"&gt;Bug BUG-000096779&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/technical-article/000022907" target="_self"&gt;Problem: Attempts to find and replace multiple data sources from enterprise geodatabase connections using Python fail&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but there are more&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.esri.com/en/Search-Results#search?q=findAndReplaceWorkspacePath" target="_self"&gt;findAndReplaceWorkspacePath issues ... sort newest to oldest&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 23:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-with-arcpy-findandreplaceworkspacepath/m-p/1000960#M59026</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-11-12T23:42:33Z</dc:date>
    </item>
  </channel>
</rss>

