I am trying to perform a batch clip using arcpy. I cannot seem to get the script to save where I want them to, with a specific name. I remove the "Ohio_" and rename them with "Summit_" what is in the directory ex. "Summit_CensusTracts".
Any input?
import arcpy
import os
from arcpy import env
arcpy.env.workspace = "H:/Python_GIS/Summit_County_Project/Shapefiles"
# Variables
fcInput = "H:/Python_GIS/Summit_County_Project/Shapefiles/Ohio_Counties.shp"
fcOutput = "H:/Python_GIS/Summit_County_Project/Shapefiles/Summit_County_Updates/Summit.shp"
# Expression
whereClause = "COUNTY_NAM = 'SUMMIT'"
# Select
arcpy.Select_analysis(fcInput, fcOutput, whereClause)
# Processing
outFolder = "H:/Python_GIS/Summit_County_Project/Shapefiles/Summit_County_Updates"
clipFeature = "H:/Python_GIS/Summit_County_Project/Shapefiles/Summit_County_Updates/Summit.shp"
shpList = ["Ohio_CensusTracts.shp", "Ohio_Cities.shp", "Ohio_Hydro.shp", "Ohio_Roads.shp"]
for root, dirs, files in os.walk(outFolder):
for name in files:
if name.startswith("Ohio_"):
# shapefile name without extension
shpName = os.path.splitext("Summit")[0]
# absolute file path
absFile = os.path.abspath(os.path.join(root,name))
# output file path
output_layer = outFolder
# buffer
arcpy.Clip_analysis(shpList, clipFeature, output_layer)