<?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: Find and Replace Workspace Path not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227086#M17592</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I found this forum posting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/55556-findAndReplaceWorkspacePaths-is-crashing-Python-script?highlight=findAndReplaceWorkspacePaths"&gt;http://forums.arcgis.com/threads/55556-findAndReplaceWorkspacePaths-is-crashing-Python-script?highlight=findAndReplaceWorkspacePaths&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had to remove the Esri and Bing map background services from my ArcMap table-of-contents to make my &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;findAndReplaceWorkspacePaths&lt;/SPAN&gt;&lt;SPAN&gt; python script work.&amp;nbsp; And, as the above mentioned forum post notes, my SDE paths were not changed in the output saveACopy MXD.&amp;nbsp; So, the script did not crash with online map background services removed, but it also did not make any path changes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Almost every map document that we create has an Esri/Bing map background service.&amp;nbsp; If Mapdocument.findAndReplaceWorkspacePaths does not work on an MXD containing online services, what are my options?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Jun 2012 13:36:48 GMT</pubDate>
    <dc:creator>JoeFlannery</dc:creator>
    <dc:date>2012-06-25T13:36:48Z</dc:date>
    <item>
      <title>Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227078#M17584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Attempting to use the find and replace workspace path, but it's returning an error message. Any suggestions on why it's not working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy
import os

ckFolder = r"\\itdhq1apt50\gis_data\testUpdatePaths\FremontCounty"
arcpy.env.workspace = ckFolder
print "Checking Folder: " + ckFolder
arcpy.AddMessage("Checking Folder: " + ckFolder)

for mDoc in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = os.path.join(ckFolder, mDoc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print fullpath
&amp;nbsp;&amp;nbsp;&amp;nbsp; #mxd = arcpy.mapping.MapDocument(ckFolder + os.sep + mDoc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("MXD Name: " + mxd)
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "FALSE")
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "\\Itdgishq\hqgis\updateDataPaths.py", line 25, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "FALSE")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'unicode' object has no attribute 'findAndReplaceWorkspacePaths'&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 15:13:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227078#M17584</guid>
      <dc:creator>MichaelMiller2</dc:creator>
      <dc:date>2012-06-21T15:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227079#M17585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Why did you comment out the line: &lt;/SPAN&gt;&lt;STRONG&gt;#mxd = arcpy.mapping.MapDocument(ckFolder + os.sep + mDoc)&lt;/STRONG&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;MapDocument&lt;/SPAN&gt;&lt;SPAN&gt; to use &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;findAndReplaceWorkspacePaths&lt;/SPAN&gt;&lt;SPAN&gt;. The value returned from os.path.join isn't a MapDocument, it's a path to a MapDocument.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 15:33:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227079#M17585</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-06-21T15:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227080#M17586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Darren for pointing that out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've revised the script as follows, and now it crashes PythonWin. I know I'm overlooking something, just not sure what it is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

#ckFolder = arcpy.GetParameterAsText(0)
ckFolder = r"\\itdhq1apt50\gis_data\testUpdatePaths\FremontCounty"
arcpy.env.workspace = ckFolder
print "Checking Folder: " + ckFolder
arcpy.AddMessage("Checking Folder: " + ckFolder)

for mDoc in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; fullPath = os.path.join(ckFolder, mDoc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(fullPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fullPath
&amp;nbsp;&amp;nbsp;&amp;nbsp; #print mxd
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "TRUE")
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Why did you comment out the line: &lt;STRONG&gt;#mxd = arcpy.mapping.MapDocument(ckFolder + os.sep + mDoc)&lt;/STRONG&gt;?&lt;BR /&gt;&lt;BR /&gt;You need a &lt;SPAN style="font-style:italic;"&gt;MapDocument&lt;/SPAN&gt; to use &lt;SPAN style="font-style:italic;"&gt;findAndReplaceWorkspacePaths&lt;/SPAN&gt;. The value returned from os.path.join isn't a MapDocument, it's a path to a MapDocument.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:03:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227080#M17586</guid>
      <dc:creator>MichaelMiller2</dc:creator>
      <dc:date>2021-12-11T11:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227081#M17587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know if this will help, but you should delete your mxd when you're done with it: del mxd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 16:19:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227081#M17587</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-06-21T16:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227082#M17588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using del mxd at the end of each loop didn't change anything.....still crashing PythonWin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I don't know if this will help, but you should delete your mxd when you're done with it: del mxd&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 16:35:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227082#M17588</guid>
      <dc:creator>MichaelMiller2</dc:creator>
      <dc:date>2012-06-21T16:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227083#M17589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;One possible issue is your "TRUE" statement in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "TRUE")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", True)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or because True is the default value, try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:03:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227083#M17589</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T11:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227084#M17590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Aparently there is a bug using this method in ArcGIS 10.0.&amp;nbsp; I'm in the process of re-working a script to accomplish this same feat using the layer class instead.&amp;nbsp; Any suggestions or guidance is appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;One possible issue is your "TRUE" statement in:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", "TRUE")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Try:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route", True)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;or because True is the default value, try:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd.findAndReplaceWorkspacePaths(r"J:\GIS\JHill\SDE_To_Route", r"\\itdgishq\hqgis\LocalRds\SDE_To_Route")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Jeff&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:03:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227084#M17590</guid>
      <dc:creator>MichaelMiller2</dc:creator>
      <dc:date>2021-12-11T11:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227085#M17591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I, too, am having no success running this code in ArcMap 10.0, SP4.&amp;nbsp; I am using code examples found in ArcGIS Online Help and running it against a very simple map and data sets.&amp;nbsp; Python crashes every time.&amp;nbsp; I have placed "print" statements in my code to see how far it goes and it gets to the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;findAndReplaceWorkspacePaths&lt;/SPAN&gt;&lt;SPAN&gt; process and crashes.&amp;nbsp; I've run out of ideas.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

# Local variables
oldSDE = r"M:\Clients\M-O\ABC\_ArcGIS\2012\06\TestingRepath\SQL01\\"
newSDE = r"M:\Clients\M-O\ABC\_ArcGIS\2012\06\TestingRepath\SQL02\\"
mapDoc = r"M:\Clients\M-O\ABC\_ArcGIS\2012\06\TestingRepath\_Map01.mxd"

print "Define MapDocument Parameter"
mxd = arcpy.mapping.MapDocument(mapDoc)

print "Start FindAndReplace Process"
mxd.findAndReplaceWorkspacePaths(oldSDE, newSDE)

print "Start saveAcopy Process"
mxd.saveACopy(r"M:\Clients\M-O\ABC\_ArcGIS\2012\06\TestingRepath\_Map01_NEW.mxd")

print "Done"

del arcpy, oldSDE, newSDE, mapDoc, mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:03:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227085#M17591</guid>
      <dc:creator>JoeFlannery</dc:creator>
      <dc:date>2021-12-11T11:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227086#M17592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I found this forum posting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/55556-findAndReplaceWorkspacePaths-is-crashing-Python-script?highlight=findAndReplaceWorkspacePaths"&gt;http://forums.arcgis.com/threads/55556-findAndReplaceWorkspacePaths-is-crashing-Python-script?highlight=findAndReplaceWorkspacePaths&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had to remove the Esri and Bing map background services from my ArcMap table-of-contents to make my &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;findAndReplaceWorkspacePaths&lt;/SPAN&gt;&lt;SPAN&gt; python script work.&amp;nbsp; And, as the above mentioned forum post notes, my SDE paths were not changed in the output saveACopy MXD.&amp;nbsp; So, the script did not crash with online map background services removed, but it also did not make any path changes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Almost every map document that we create has an Esri/Bing map background service.&amp;nbsp; If Mapdocument.findAndReplaceWorkspacePaths does not work on an MXD containing online services, what are my options?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 13:36:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227086#M17592</guid>
      <dc:creator>JoeFlannery</dc:creator>
      <dc:date>2012-06-25T13:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227087#M17593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The Bing maps services issue is fixed with 10.1 SP1&amp;nbsp; (NIM081549).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 14:08:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227087#M17593</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-06-25T14:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find and Replace Workspace Path not working</title>
      <link>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227088#M17594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apparently it's a bug that's resolved in 10.1.&amp;nbsp; See below for the response from ESRI:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The errors you're seeing in regards to using the functions of the Map Document class are because of an existing bug in our system, which is fixed at version 10.1.&amp;nbsp; The way to get around these errors would be to either 1) Remove all layers from your map that don't support the WORKSPACEPATH or DATASOURCE properties (i.e. Basemap layers, Layers from ArcGIS Services, etc.) or to use the Layer class instead of the map document class.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the layer class solves the issue.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 17:16:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-and-replace-workspace-path-not-working/m-p/227088#M17594</guid>
      <dc:creator>MichaelMiller2</dc:creator>
      <dc:date>2012-06-25T17:16:08Z</dc:date>
    </item>
  </channel>
</rss>

