<?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 Set Folder Output for ArcGIS Pro Python Script Tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306613#M68110</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I created a script that runs successfully in the ArcGIS Pro python window, but I would like to re-create this as a script tool to eventually be used for a geoprocessing service.&amp;nbsp; I am having problems setting the output folder in the script tool.&amp;nbsp; What is the correct data type to use when setting up the tool parameters?&amp;nbsp; I've tried "Folder", "Workspace", and "String" with no success. (See below)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shildebrand_0-1688752772008.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75012i0E54FD24721DE8F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shildebrand_0-1688752772008.png" alt="shildebrand_0-1688752772008.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically the script copies files from a file directory based off a user selection and a hyperlink to the file using the "LINK" field.&amp;nbsp; Any suggestions would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the original python window script that runs successfully:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;import shutil&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;# Change to Name of Working Map&lt;BR /&gt;map = aprx.listMaps("Map")[0]&lt;BR /&gt;# Change to the location of the plan ref layer in your map&lt;BR /&gt;fc = map.listLayers()[0]&lt;BR /&gt;print(fc)&lt;BR /&gt;cursor = arcpy.SearchCursor(fc)&lt;BR /&gt;for row in cursor:&lt;BR /&gt;field = "LINK"&lt;BR /&gt;link = (row.getValue(field))&lt;BR /&gt;head, tail = os.path.split(str(link))&lt;BR /&gt;print ("Downloading: " + tail)&lt;BR /&gt;# Set Download Location&lt;BR /&gt;dest_path = r"H:\Data Requests\ExportFolder"&lt;BR /&gt;shutil.copy(link, dest_path)&lt;/P&gt;&lt;P&gt;print("Download Complete")&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the script tool code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;import shutil&lt;/P&gt;&lt;P&gt;fc = arcpy.GetParameterAsText(0)&lt;BR /&gt;print(fc)&lt;BR /&gt;cursor = arcpy.SearchCursor(fc)&lt;BR /&gt;for row in cursor:&lt;BR /&gt;field = "LINK"&lt;BR /&gt;link = (row.getValue(field))&lt;BR /&gt;head, tail = os.path.split(str(link))&lt;BR /&gt;print ("Downloading: " + tail)&lt;BR /&gt;# Set Download Location&lt;BR /&gt;dest_path = arcpy.GetParameterAsText(1)&lt;BR /&gt;shutil.copy(link, dest_path)&lt;/P&gt;&lt;P&gt;print("Download Complete")&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jul 2023 18:01:21 GMT</pubDate>
    <dc:creator>shildebrand</dc:creator>
    <dc:date>2023-07-07T18:01:21Z</dc:date>
    <item>
      <title>Set Folder Output for ArcGIS Pro Python Script Tool</title>
      <link>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306613#M68110</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I created a script that runs successfully in the ArcGIS Pro python window, but I would like to re-create this as a script tool to eventually be used for a geoprocessing service.&amp;nbsp; I am having problems setting the output folder in the script tool.&amp;nbsp; What is the correct data type to use when setting up the tool parameters?&amp;nbsp; I've tried "Folder", "Workspace", and "String" with no success. (See below)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shildebrand_0-1688752772008.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75012i0E54FD24721DE8F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shildebrand_0-1688752772008.png" alt="shildebrand_0-1688752772008.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically the script copies files from a file directory based off a user selection and a hyperlink to the file using the "LINK" field.&amp;nbsp; Any suggestions would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the original python window script that runs successfully:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;import shutil&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;# Change to Name of Working Map&lt;BR /&gt;map = aprx.listMaps("Map")[0]&lt;BR /&gt;# Change to the location of the plan ref layer in your map&lt;BR /&gt;fc = map.listLayers()[0]&lt;BR /&gt;print(fc)&lt;BR /&gt;cursor = arcpy.SearchCursor(fc)&lt;BR /&gt;for row in cursor:&lt;BR /&gt;field = "LINK"&lt;BR /&gt;link = (row.getValue(field))&lt;BR /&gt;head, tail = os.path.split(str(link))&lt;BR /&gt;print ("Downloading: " + tail)&lt;BR /&gt;# Set Download Location&lt;BR /&gt;dest_path = r"H:\Data Requests\ExportFolder"&lt;BR /&gt;shutil.copy(link, dest_path)&lt;/P&gt;&lt;P&gt;print("Download Complete")&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the script tool code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;import os&lt;BR /&gt;import shutil&lt;/P&gt;&lt;P&gt;fc = arcpy.GetParameterAsText(0)&lt;BR /&gt;print(fc)&lt;BR /&gt;cursor = arcpy.SearchCursor(fc)&lt;BR /&gt;for row in cursor:&lt;BR /&gt;field = "LINK"&lt;BR /&gt;link = (row.getValue(field))&lt;BR /&gt;head, tail = os.path.split(str(link))&lt;BR /&gt;print ("Downloading: " + tail)&lt;BR /&gt;# Set Download Location&lt;BR /&gt;dest_path = arcpy.GetParameterAsText(1)&lt;BR /&gt;shutil.copy(link, dest_path)&lt;/P&gt;&lt;P&gt;print("Download Complete")&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 18:01:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306613#M68110</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2023-07-07T18:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Set Folder Output for ArcGIS Pro Python Script Tool</title>
      <link>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306633#M68111</link>
      <description>&lt;P&gt;It would help get responses if you could format your code to make it more readable:&lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_blank"&gt;&amp;nbsp;https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 18:57:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306633#M68111</guid>
      <dc:creator>ChrisRingo</dc:creator>
      <dc:date>2023-07-07T18:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set Folder Output for ArcGIS Pro Python Script Tool</title>
      <link>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306638#M68112</link>
      <description>&lt;P&gt;Thanks Chris for the suggestion - yes that is better!&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the original python window script that runs successfully:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
import shutil
aprx = arcpy.mp.ArcGISProject("CURRENT")
# Change to Name of Working Map
map = aprx.listMaps("Map")[0]
# Change to the location of the plan ref layer in your map
fc = map.listLayers()[0]
print(fc)
cursor = arcpy.SearchCursor(fc)
for row in cursor:
    field = "LINK"
    link = (row.getValue(field))
    head, tail = os.path.split(str(link))
    print ("Downloading: " + tail)
    # Set Download Location
    dest_path = r"H:\Data Requests\ExportFolder"
    shutil.copy(link, dest_path)

print("Download Complete")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the script tool code:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
import shutil

fc = arcpy.GetParameterAsText(0)
print(fc)
cursor = arcpy.SearchCursor(fc)
for row in cursor:
    field = "LINK"
    link = (row.getValue(field))
    head, tail = os.path.split(str(link))
    print ("Downloading: " + tail)
    # Set Download Location
    dest_path = arcpy.GetParameterAsText(1)
    shutil.copy(link, dest_path)

print("Download Complete")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 19:11:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306638#M68112</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2023-07-07T19:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Set Folder Output for ArcGIS Pro Python Script Tool</title>
      <link>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306684#M68113</link>
      <description>&lt;P&gt;Probably either Folder or Workspace (or even String) would work for the parameter type for "out_folder", but you'll want to change the direction to "Input". Even though you'll be writing files to that folder, it's still an input parameter.&lt;/P&gt;&lt;P&gt;Also, just in the interest of more elegant coding, you should move the statement "dest_path = arcpy.GetParameterAsText(1)" up to the top and out of the loop - it only needs to be executed once.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 20:40:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306684#M68113</guid>
      <dc:creator>ChrisRingo</dc:creator>
      <dc:date>2023-07-07T20:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: Set Folder Output for ArcGIS Pro Python Script Tool</title>
      <link>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306699#M68114</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp; Switching the folder to an input parameter did the trick!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jul 2023 21:17:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-folder-output-for-arcgis-pro-python-script/m-p/1306699#M68114</guid>
      <dc:creator>shildebrand</dc:creator>
      <dc:date>2023-07-07T21:17:03Z</dc:date>
    </item>
  </channel>
</rss>

