<?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: python expression for changing file path in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185347#M2018</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14192593259522034 jive_text_macro" jivemacro_uid="_14192593259522034"&gt;&lt;P&gt;!Links!.replace("W:", "V:")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where 'Links' is the field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="screen1.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/42931_screen1.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Dec 2014 14:42:25 GMT</pubDate>
    <dc:creator>JakeSkinner</dc:creator>
    <dc:date>2014-12-22T14:42:25Z</dc:date>
    <item>
      <title>python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185346#M2017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What would be the proper syntax if I want to use the "replace" python function in ArcMap field calculator to replace a file path with a new one.&lt;/P&gt;&lt;P&gt;for example the current links path is &lt;STRONG&gt;W:\folder name\file name&lt;/STRONG&gt; I want to replace just the "W:\" with "V:\" Any help would be great. Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Dec 2014 16:44:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185346#M2017</guid>
      <dc:creator>ErikBlake</dc:creator>
      <dc:date>2014-12-17T16:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185347#M2018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erik,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14192593259522034 jive_text_macro" jivemacro_uid="_14192593259522034"&gt;&lt;P&gt;!Links!.replace("W:", "V:")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where 'Links' is the field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="screen1.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/42931_screen1.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 14:42:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185347#M2018</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-12-22T14:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185348#M2019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jake. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 16:37:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185348#M2019</guid>
      <dc:creator>ErikBlake</dc:creator>
      <dc:date>2014-12-22T16:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185349#M2020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jake&lt;/P&gt;&lt;P&gt;would you possibly know how I would use python to replace "\" with "/" this occurrence happens in the middle of the links string. So for example: V:\folder\folder\filename&lt;/P&gt;&lt;P&gt;I was able to get the "\" replaced up to the last one by using the replace function in arcmap by doing this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;!LINKS!.replace("\foldername" , "/foldername")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However when i try to replace the text ending in the backslash it errors out. For example: &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;!LINKS!.replace("foldername\" , "foldername/")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Any suggestion would be great help. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 20:30:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185349#M2020</guid>
      <dc:creator>ErikBlake</dc:creator>
      <dc:date>2014-12-22T20:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185350#M2021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe you should use some &lt;EM&gt;os.path&lt;/EM&gt; methods:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os

path = r"V:/blah\blah/blah\blah"
print os.path.normcase(path)
# &amp;gt;&amp;gt; v:\blah\blah\blah\blah

path = r"V://blah\blah/blah\\blah"
print os.path.normpath(path)
# &amp;gt;&amp;gt; V:\blah\blah\blah\blah&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:24:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185350#M2021</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T09:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185351#M2022</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xander&lt;/P&gt;&lt;P&gt;Thanks for your time and help. Excuse my ignorance, but I have just a little experience in python. So I want to do this on a field in one of our layers that contains these file path to be used to access links through our web maps. Is it still possible to use the method you showed above. And do I do it inside python in arcmap from the geoprocessing toolbar. Thanks again for your help.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2014 13:24:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185351#M2022</guid>
      <dc:creator>ErikBlake</dc:creator>
      <dc:date>2014-12-23T13:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185352#M2023</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using double back slashes.&amp;nbsp; Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;!Links!.replace("W:\\folder\\folder", "V:\\folder2\\folder2")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2014 13:49:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185352#M2023</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-12-23T13:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: python expression for changing file path</title>
      <link>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185353#M2024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jake/Xander&lt;/P&gt;&lt;P&gt;Thanks guys for your help. I just ended up exporting the layer to dbf and made the changes in excel and then rejoined back to the layer in ArcMap and did a field calculation. Much easier for me that way. But just wanted to say thanks for your help and suggestions. Trying to get backslashes changed to forward slashes is still a little beyond my skill set with python. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Dec 2014 17:40:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/python-expression-for-changing-file-path/m-p/185353#M2024</guid>
      <dc:creator>ErikBlake</dc:creator>
      <dc:date>2014-12-23T17:40:40Z</dc:date>
    </item>
  </channel>
</rss>

