<?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: Adding extra files to a zip? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/adding-extra-files-to-a-zip/m-p/761342#M58725</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming this is your own data that you are trying to .zip, and the script is one you received from someone else.....do you even have a "term of use" and "metadata" file created?&amp;nbsp; It is good to have these items before you distribute data, as a general business practice, but if you don't you can either created the files now, or comment out that line.&amp;nbsp; but I would suggest at least writing up minimal terms and metadata and saving as PDF in the path shown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;btw...I'm assuming your data is in the same location.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jan 2016 14:28:01 GMT</pubDate>
    <dc:creator>RebeccaStrauch__GISP</dc:creator>
    <dc:date>2016-01-19T14:28:01Z</dc:date>
    <item>
      <title>Adding extra files to a zip?</title>
      <link>https://community.esri.com/t5/python-questions/adding-extra-files-to-a-zip/m-p/761340#M58723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I got this fantastic script from: &lt;A href="https://community.esri.com/message/76103"&gt;Script for Making Individual Zip file for Each Shapefile?&lt;/A&gt; but I required some extra files to be added to each of the individual zips, e.g. 2 pdfs: one with metadata and another for terms and conditions.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcgisscripting, os, glob, zipfile, shutil&lt;/P&gt;&lt;P&gt;from os import path as p&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Create the Geoprocessor object&lt;/P&gt;&lt;P&gt;gp = arcgisscripting.create()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# arcpy.overwriteOutput = True&lt;/P&gt;&lt;P&gt;gp.overwriteoutput=1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def ZipShapes(path, out_path):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.workspace = path&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes = gp.ListFeatureClasses("*")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # iterate through list of shapefile&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for shape in iter(shapes.next, None):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = p.splitext(shape)[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zip_path = p.join(out_path, name + '.zip')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.chdir(path)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for files in glob.glob('%s.*' %name):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zip.write(p.join(path,files), files)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'All files written to %s' %zip_path&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # copy pdf files to zip folder&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in pdfList:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copyfile(os.path.join(os.path.dirname(path),f), os.path.join(path,f))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zip.close()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; path = r'S:\Species\MARINEFISH'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; outpath = r'S:\Species\MARINEFISH\ZIPS'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pdfList =["Terms &amp;amp; Conditions of Use.pdf", "METADATA.pdf"]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ZipShapes(path, outpath)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I keep getting the error:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "S:\scripts\Python\Zipping_Shapefiles", line 34, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ZipShapes(path, outpath)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "S:\scripts\Python\Zipping_Shapefiles", line 25, in ZipShapes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shutil.copyfile(os.path.join(os.path.dirname(path),f), os.path.join(path,f))&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Python27\ArcGIS10.3\lib\shutil.py", line 82, in copyfile&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; with open(src, 'rb') as fsrc:&lt;/P&gt;&lt;P&gt;IOError: [Errno 2] No such file or directory: 'S:\\Species\\METADATA.pdf'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jan 2016 13:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-extra-files-to-a-zip/m-p/761340#M58723</guid>
      <dc:creator>JemmaWindow</dc:creator>
      <dc:date>2016-01-19T13:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding extra files to a zip?</title>
      <link>https://community.esri.com/t5/python-questions/adding-extra-files-to-a-zip/m-p/761341#M58724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you already look at the obvious issue of &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;'S:\\Species\\METADATA.pdf' not actually existing? Where is the metadata file located? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Also it looks like you are trying to copy your pdfs to the wrong place? &lt;SPAN style="font-weight: bold; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; os.path.join(path,f) &lt;/SPAN&gt;​would attempt to copy the pdfs to &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;'S:\Species\MARINEFISH\ [PDFName]'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jan 2016 14:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-extra-files-to-a-zip/m-p/761341#M58724</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2016-01-19T14:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Adding extra files to a zip?</title>
      <link>https://community.esri.com/t5/python-questions/adding-extra-files-to-a-zip/m-p/761342#M58725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming this is your own data that you are trying to .zip, and the script is one you received from someone else.....do you even have a "term of use" and "metadata" file created?&amp;nbsp; It is good to have these items before you distribute data, as a general business practice, but if you don't you can either created the files now, or comment out that line.&amp;nbsp; but I would suggest at least writing up minimal terms and metadata and saving as PDF in the path shown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;btw...I'm assuming your data is in the same location.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jan 2016 14:28:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-extra-files-to-a-zip/m-p/761342#M58725</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-01-19T14:28:01Z</dc:date>
    </item>
  </channel>
</rss>

