I'm trying to write a program that clips all the features in a workspace. I've read through several similar threads on this website, but still am having trouble understanding what is wrong with my program.

# This program clips all roads, state roads, railroads, steams, rivers, and
# land use using the Meridian Township boundary.  Each clipped dataset is
# renamed to the base name plus "_Meridian.shp"

import arcpy

arcpy.env.workspace = "F:/data"

clipFeature = 'Meridian.shp'

appendstring = '_Meridian'

featureClassList = arcpy.ListFeatureClasses()
# this gets the base name variable
clipFeatureName = arcpy.Describe(clipFeature)
clipName = str(clipFeatureName.baseName)

    for featureClass in featureClassList:
        featureClassDescription = arcpy.Describe(featureClass)
        featureClassList = arcpy.ListFeatureClasses()
        #this gets the base name variable
        nameString = str(featureClassDescription.baseName)
        arcpy.Clip_analysis(featureClassList, clipFeature, "F:/output")

        # this statement prevents the clip feature from clipping itself.
        if nameString == clipName:
            namething = nameString + appendstring
            print namething

    print arcpy.GetMessages(2)

Update: My program does not produce an error message, but when I look in my output folder in arccatalog, it is empty.

  • What's the problem? Oct 24, 2017 at 18:45
  • Sorry, I edited my post to include the error message. Oct 24, 2017 at 18:52
  • The error message means that Meridian.shp isn't in folder F:/data. Oct 24, 2017 at 18:59
  • I had a typo in the path name. But now, when I run the program, there is no error message, but my output folder is empty after refreshing arcCatalog. Oct 24, 2017 at 19:03
  • 1
    You should update your post, or remove the error message, I didn't realize you figure out the error and now have a different issue.
    – whyzar
    Oct 24, 2017 at 19:16

1 Answer 1


Try something like this, it's simple and works.

# http://pro.arcgis.com/en/pro-app/tool-reference/analysis/clip.htm
import arcpy
from arcpy import env

# Set workspace
env.workspace = "C:/data/demo"

fc = arcpy.ListFeatureClasses()

for i in fc:
    if (i != "clip.shp"):
        in_features = i
        clip_features = "clip.shp"
        out_feature_class = "C:/data/output/"+i
        arcpy.Clip_analysis(in_features, clip_features, out_feature_class)

print "Done"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.