<?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: Reset the paths script in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857524#M597</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; overflow-wrap: break-word; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;So far so good... working a new numpy-based data structure for geometry.&amp;nbsp; Inputs can be derived from arcpy and/or geojson objects. Certainly speeds up geometry processing compared to cursors &lt;/SPAN&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2019 23:38:58 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2019-07-16T23:38:58Z</dc:date>
    <item>
      <title>Reset the paths script</title>
      <link>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857519#M592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to get a script to reset the paths of data sources from an archive path to a current path. However, the script is only changing one of the paths and not all of the paths. Here is my code:&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;BR /&gt;arcpy.AddMessage("\n\n" + "Re-source MXDs was developed by Carl Beyerhelm, modified by Steve Kovach" + "\n")&lt;BR /&gt;mxdFolder = arcpy.GetParameterAsText(0)&amp;nbsp; ## The project MXD folder&lt;BR /&gt;oldFolder&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.GetParameterAsText(1)&amp;nbsp; ## The archived data folder path&lt;BR /&gt;newFolder&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.GetParameterAsText(2)&amp;nbsp; ## The current data folder path&lt;BR /&gt;arcpy.env.workspace = mxdFolder&lt;BR /&gt;mxdList = arcpy.ListFiles("*.mxd")&amp;nbsp; ## Get a list of the MXDs&lt;BR /&gt;for mxd in mxdList:&amp;nbsp; ## For each MXD&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("\n" + "Re-sourcing " + mxd + "...")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDoc = arcpy.mapping.MapDocument(os.path.join(mxdFolder, mxd))&amp;nbsp; ## Get the mapDoc object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDoc.findAndReplaceWorkspacePaths(r"oldFolder", r"newFolder", True)&amp;nbsp; ## Replace the obsolete path with the new path&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDoc.save()&amp;nbsp; ## Save the updated MXD&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; del mapDoc&amp;nbsp; ## Release the mapDoc object&lt;BR /&gt;arcpy.AddMessage("\n\n" + "OK, done!" + "\n\n")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas where I'm going wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2019 21:58:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857519#M592</guid>
      <dc:creator>SteveKovach</dc:creator>
      <dc:date>2019-07-16T21:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reset the paths script</title>
      <link>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857520#M593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you have to raw encode the actual value of the variable, not the variable name, so I would make sure that what is assigned to the variable name is indeed correct, as in the examples below&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;oldFolder &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"c:\a path\not\right"&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;oldFolder&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
c&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; path
ight

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"oldfolder"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
oldfolder

fixed &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"c:\a path\not\right"&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fixed&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
c&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;\a path\&lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt;\right&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:36:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857520#M593</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T10:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reset the paths script</title>
      <link>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857521#M594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/343027" target="_blank"&gt;Steven,&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I formatted your code to be a little easier to read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"\n\n"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Re-source MXDs was developed by Carl Beyerhelm, modified by Steve Kovach"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

mxdFolder &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## The project MXD folder&lt;/SPAN&gt;
oldFolder &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## The archived data folder path&lt;/SPAN&gt;
newFolder &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## The current data folder path&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; mxdFolder
mxdList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFiles&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"*.mxd"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## Get a list of the MXDs&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; mxd &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; mxdList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## For each MXD&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"\n"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Re-sourcing "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; mxd &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"..."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    mapDoc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxdFolder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## Get the mapDoc object&lt;/SPAN&gt;
    mapDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;findAndReplaceWorkspacePaths&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;oldFolder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; newFolder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## Replace the obsolete path with the new path&lt;/SPAN&gt;
    mapDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;  &lt;SPAN class="comment token"&gt;## Save the updated MXD&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; mapDoc  &lt;SPAN class="comment token"&gt;## Release the mapDoc object&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"\n\n"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"OK, done!"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\n\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to use the variable names oldFolder and newFolder alone in line 15 above not as raw strings.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:36:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857521#M594</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2021-12-12T10:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reset the paths script</title>
      <link>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857522#M595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;because the problem will be as shown in my lines 6 and 11 &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2019 23:20:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857522#M595</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-07-16T23:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reset the paths script</title>
      <link>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857523#M596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I needed to be quicker to get a reply in ahead you when it is a Python question. &amp;nbsp;How’s retirement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2019 23:31:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857523#M596</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2019-07-16T23:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reset the paths script</title>
      <link>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857524#M597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; overflow-wrap: break-word; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;So far so good... working a new numpy-based data structure for geometry.&amp;nbsp; Inputs can be derived from arcpy and/or geojson objects. Certainly speeds up geometry processing compared to cursors &lt;/SPAN&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2019 23:38:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/reset-the-paths-script/m-p/857524#M597</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-07-16T23:38:58Z</dc:date>
    </item>
  </channel>
</rss>

