So I got this fantastic script from: Script for Making Individual Zip file for Each Shapefile? 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.
import arcgisscripting, os, glob, zipfile, shutil
from os import path as p
# Create the Geoprocessor object
gp = arcgisscripting.create()
# arcpy.overwriteOutput = True
def ZipShapes(path, out_path):
gp.workspace = path
shapes = gp.ListFeatureClasses("*")
# iterate through list of shapefile
for shape in iter(shapes.next, None):
name = p.splitext(shape)
zip_path = p.join(out_path, name + '.zip')
zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
for files in glob.glob('%s.*' %name):
print 'All files written to %s' %zip_path
# copy pdf files to zip folder
for f in pdfList:
if __name__ == '__main__':
path = r'S:\Species\MARINEFISH'
outpath = r'S:\Species\MARINEFISH\ZIPS'
pdfList =["Terms & Conditions of Use.pdf", "METADATA.pdf"]
I keep getting the error:
Traceback (most recent call last):
File "S:\scripts\Python\Zipping_Shapefiles", line 34, in <module>
File "S:\scripts\Python\Zipping_Shapefiles", line 25, in ZipShapes
File "C:\Python27\ArcGIS10.3\lib\shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'S:\\Species\\METADATA.pdf'
Any help would be greatly appreciated!