The following code (10.1 + only) walks through a directory and finds FeatureClasses (this example assumes a folder of "zip" files).It then copies each one into a fGDB. You can change what it does, but the logic in it should start you off.You'll notice that a directory is created inside the scratchFolder (the variable "ZipFolder") - this is where the uploaded ZipFile is extracted to. Then the code looks in there.
import arcpy
import zipfile
import os
inFile = arcpy.GetParameterAsText(0)
# Create a folder in the scratch directory to extract zip to
zipFolder = os.path.join(arcpy.env.scratchFolder, "zipContents")
os.mkdir(zipFolder)
# Extract the zip contents
zip2Extract = zipfile.ZipFile(inFile, 'r')
zip2Extract.extractall(zipFolder)
zip2Extract.close()
# Create a folder in the scratch directory to hold the fgdb which will be downloaded
fgdbFolder = os.path.join(arcpy.env.scratchFolder, "fgdbOutput")
os.mkdir(fgdbFolder)
# Work through all the FeatureClasses inside the extracted zip folder
for dirpath, dirnames, filenames in arcpy.da.Walk(zipFolder, datatype="FeatureClass"):
for filename in filenames:
# You could replace the code below here with your own code to do what you want....
arcpy.AddMessage("Copying: {}".format(filename))
# Strip .shp from the filename when merging shapefiles
if filename.endswith("shp"):
outFilename = filename[:-4]
else:
outFilename = filename
# Copy each featureclass into the output.gdb
arcpy.CopyFeatures_management(os.path.join(dirpath, filename),
os.path.join(fgdbFolder, "output.gdb", outFilename))