<?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: Script Tool Python Question in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690254#M27710</link>
    <description>&lt;P&gt;Thank you very much for your help.&amp;nbsp; It is working now, the issue was I had it as ".zip".&amp;nbsp; Thank you again!&lt;/P&gt;</description>
    <pubDate>Thu, 12 Mar 2026 16:00:46 GMT</pubDate>
    <dc:creator>GaryMorris</dc:creator>
    <dc:date>2026-03-12T16:00:46Z</dc:date>
    <item>
      <title>Script Tool Python Question</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690176#M27702</link>
      <description>&lt;P&gt;I am trying to create a script tool to use in a model.&amp;nbsp; The purpose of the script tool is to take files that have been exported to a folder and zip them into a different folder.&amp;nbsp; I am getting an error:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Scratch_Catalog\ZipFile_Export.py", line 33, in &amp;lt;module&amp;gt;&lt;BR /&gt;zip_folder(input_folder, output_zip)&lt;BR /&gt;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;File "C:\Scratch_Catalog\ZipFile_Export.py", line 15, in zip_folder&lt;BR /&gt;with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:&lt;BR /&gt;~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^&lt;BR /&gt;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\zipfile\__init__.py", line 1367, in __init__&lt;BR /&gt;self.fp = io.open(file, filemode)&lt;BR /&gt;~~~~~~~^^^^^^^^^^^^^^^^&lt;BR /&gt;PermissionError: [Errno 13] Permission denied: 'C:\\Scratch_Catalog\\ZipTest'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that is a lot but even after research I am not understanding the error.&amp;nbsp; Here is the attempted code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def zip_folder(input_folder, output_zip):
    """Compresses the contents of a folder into a ZIP file."""
    if not os.path.exists(input_folder):
        arcpy.AddError(f"Input folder does not exist: {input_folder}")
        sys.exit(1)

    # Ensure output directory exists
    os.makedirs(os.path.dirname(output_zip), exist_ok=True)

    with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
        for root, _, files in os.walk(input_folder):
            for file in files:
                file_path = os.path.join(root, file)
                arcname = os.path.relpath(file_path, input_folder)
                zipf.write(file_path, arcname)

    arcpy.AddMessage(f"Created ZIP file: {output_zip}")

    """Clear all cached workspaces"""
    arcpy.management.ClearWorkspaceCache()
	


if __name__ == "__main__":
    # Script tool parameters
    input_folder = arcpy.GetParameterAsText(0)  # Input folder
    output_zip = arcpy.GetParameterAsText(1)    # Output ZIP file path
    zip_folder(input_folder, output_zip)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 12:23:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690176#M27702</guid>
      <dc:creator>GaryMorris</dc:creator>
      <dc:date>2026-03-12T12:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Python Question</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690193#M27703</link>
      <description>&lt;P&gt;That's odd. I copy-pasted your code exactly and it ran fine for me.&lt;/P&gt;&lt;P&gt;I'm assuming the error is on the output path, so what happens if you pick a different output folder?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 13:21:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690193#M27703</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-03-12T13:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Python Question</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690201#M27704</link>
      <description>&lt;P&gt;I get the same error, seemingly no matter what I do with the input and output.&amp;nbsp; I have tried changing the parameter values from folder to feature class, shapefile, or folder and mapping to them as well as changing the output folder location.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In every case I am getting the same error.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 13:48:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690201#M27704</guid>
      <dc:creator>GaryMorris</dc:creator>
      <dc:date>2026-03-12T13:48:22Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Python Question</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690211#M27705</link>
      <description>&lt;P&gt;This is my setup&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-03-12 081402.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/149746iFDBC617607957B7E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2026-03-12 081402.png" alt="Screenshot 2026-03-12 081402.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-03-12 081446.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/149747i0F6BC807F78971A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2026-03-12 081446.png" alt="Screenshot 2026-03-12 081446.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;To confirm, your second parameter should be of "File" type (and then filtered to zips)&lt;/P&gt;&lt;P&gt;Are you able to do other work in that folder? Like an arcpy.management.CreateFeatureclass()&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/create-feature-class.htm" target="_blank"&gt;Create Feature Class (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 14:17:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690211#M27705</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-03-12T14:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Python Question</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690242#M27707</link>
      <description>&lt;P&gt;I definitely had the parameters setup wrong.&amp;nbsp; I changed them to match yours.&amp;nbsp; For the output, you filtered the file by ".zip"?&amp;nbsp; &amp;nbsp;I tried that and I can't even run the tool, I get the red X on the output parameter telling me it has to be a .zip file, which is confusing because the tool has not ran to create the .zip file.&lt;/P&gt;&lt;P&gt;I'm sure at this point this is operator error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 15:22:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690242#M27707</guid>
      <dc:creator>GaryMorris</dc:creator>
      <dc:date>2026-03-12T15:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Python Question</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690249#M27709</link>
      <description>&lt;P&gt;The file filter just wants the extension without the period. So "zip", not ".zip"&lt;/P&gt;&lt;P&gt;Also, making sure that it's an output parameter.&lt;/P&gt;&lt;P&gt;Here's mine (attached)&lt;/P&gt;&lt;P&gt;I did get an error when I tried to zip a folder where there was an active lockfile on something inside btw.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 15:50:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690249#M27709</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-03-12T15:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Python Question</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690254#M27710</link>
      <description>&lt;P&gt;Thank you very much for your help.&amp;nbsp; It is working now, the issue was I had it as ".zip".&amp;nbsp; Thank you again!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 16:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/script-tool-python-question/m-p/1690254#M27710</guid>
      <dc:creator>GaryMorris</dc:creator>
      <dc:date>2026-03-12T16:00:46Z</dc:date>
    </item>
  </channel>
</rss>

