The script below is functional, but it runs into issues if it comes across duplicate files (even when overwriteOutput=True) and corrupt shapefiles when running feature to feature.
Are there exceptions I can add that will either skip these features if they already exist in the database, or continue running the script if it runs into an error adding a shapefile to a geodatabasing?
This is the script that I am trying to add the error handling to. The script performs the following actions:
- Walk through a directory and compile a list of shapefiles
- Add the shapefiles to a geodatabase
import arcpy, os, fnmatch from arcpy import env env.overwriteOutput=True rootDir = "whatever directory" search = "whatever criteria" outGDB = "whatever GDB" shpLst =  for root, dirs., files in os.walk(rootDir, topdown=True): for filename in fnmatch.filter(files, search): shpLst.append(os.path.join(root, filename)) for fc in shpLst: date = os.path.basename(fc).split("_") outName = os.path.basename(fc)[9:].replace(".shp", "_") + date arcpy.FeatureClassToFeatureClass_management(fc, outGDB, outName, "", "", "") print outName + " sent to " + outGDB