<?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: File Path Lists and arcpy.GetParameterAsText in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78930#M6371</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; p &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"c:\path1;c:\path2"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; pths &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; p&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"\\"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"/"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;";"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; pths
&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'c:/path1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'c:/path2'&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if you can't append an 'r' to the paths, don't worry about it, just replace and split. &amp;nbsp;forward slashes are just fine if you can't do the double backslashes.&lt;/P&gt;&lt;P&gt;There are other ways, but it is Monday&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:02:51 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2021-12-10T23:02:51Z</dc:date>
    <item>
      <title>File Path Lists and arcpy.GetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78928#M6369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This probably comes under the category of &amp;nbsp;'let me Google that for you', but anyway:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to write an ArcToolbox tool using a Python script I've already created. The script relies on a list of files, of which I've set up in the toolbox parameters as type 'Any' and multivalue = Yes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My issue is that if I use arcpy.GetParameterAsText, the variable returns a string, which can be converted to a list by .split(';'), but then the backslashes used in the file path do strange things to my output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try as I may, I cannot think of an easy way of converting '\' to '\\' to solve my issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried using arcpy.GetParameter, but this does not suit my need, as this returns a list of geoprocessing objects, and I need to extract part of the file name for a subsequent step in my process. Unless there's an easy way to convert this GP object to a text name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Feeling a little fragile after the weekend, and my brain is not comprehending this particular issue on a Monday! Please help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2016 03:48:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78928#M6369</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-09-19T03:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Lists and arcpy.GetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78929#M6370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using "r" in front of the string. It just like the "@" in C#&lt;/P&gt;&lt;P&gt;It tell the software to ignore the usual meaning of the slash and use it as simple char.&lt;/P&gt;&lt;P&gt;x = r"C:\temp"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have fun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2016 04:58:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78929#M6370</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2016-09-19T04:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Lists and arcpy.GetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78930#M6371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; p &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"c:\path1;c:\path2"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; pths &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; p&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;replace&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"\\"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"/"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;split&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;";"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; pths
&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'c:/path1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'c:/path2'&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if you can't append an 'r' to the paths, don't worry about it, just replace and split. &amp;nbsp;forward slashes are just fine if you can't do the double backslashes.&lt;/P&gt;&lt;P&gt;There are other ways, but it is Monday&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:02:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78930#M6371</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-10T23:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Lists and arcpy.GetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78931#M6372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Mody. The issue was (is?) was converting the string I already had to the 'raw' string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway - after lunch and a coffee, I was able to troubleshoot the issue and get a resolution. I've gone back to using arcpy.GetParameter, and then using arcpy.Describe on the geoprocessing object to extract the file name and path, and then using os.path.join to concatenate the two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Convoluted but it seems to be working!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2016 05:48:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78931#M6372</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-09-19T05:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Lists and arcpy.GetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78932#M6373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Dan. I spent an age stuffing around with .replace, your solution is the one that I didn't try!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem solved.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2016 05:51:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78932#M6373</guid>
      <dc:creator>AnthonyCheesman1</dc:creator>
      <dc:date>2016-09-19T05:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: File Path Lists and arcpy.GetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78933#M6374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now that you have had some coffee...&amp;nbsp;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/filenames-and-file-paths-in-python"&gt;/blogs/dan_patterson/2016/08/14/filenames-and-file-paths-in-python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2016 05:59:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/file-path-lists-and-arcpy-getparameterastext/m-p/78933#M6374</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-09-19T05:59:46Z</dc:date>
    </item>
  </channel>
</rss>

