Here is my script:

import arcpy

# set environment, workspace, and output location

arcpy.env.overwriteOutput = 1

arcpy.env.workspace = r"Database Connections\Transportation.sde"

output_loc = r"C:\Users\johndiaz\Documents\Outerspatial_Shapefiles"

agency_list = ['CASP', 'CIC', 'MRCA/SMMC', 'LACODPR', 'NPS', 'PCTA']

# assign variables to layers

th_fc = r"Database Connections\Transportation.sde\eGIS_Transportation.EGIS.DPR_TRAILHEADS"
poi_fc = r"Database Connections\Transportation.sde\eGIS_Transportation.EGIS.DPR_TRAILS_POI"
trails_fc = r"Database Connections\Transportation.sde\eGIS_Transportation.EGIS.DPR_TRAILS"

# shapefiles for trailheads and poi
for list in agency_list:
    print "generating trailhead and poi shapefiles"
    where_clause = "agency = '" + list + "'"
    arcpy.MakeFeatureLayer_management (th_fc, "th_lyr")
    arcpy.SelectLayerByAttribute_management ("th_lyr", "NEW_SELECTION", where_clause)
    output_th = "\\" + list + "_TRAILHEADS.shp"
    arcpy.FeatureClassToFeatureClass_conversion ("th_lyr", output_loc, output_th)
    arcpy.MakeFeatureLayer_management (poi_fc, "poi_lyr")
    arcpy.SelectLayerByAttribute_management ("poi_lyr", "NEW_SELECTION", where_clause)
    output_poi = "\\" + list + "_POI.shp"
    arcpy.FeatureClassToFeatureClass_conversion ("poi_lyr", output_loc, output_poi)
    print "trailhead and poi shapefiles complete"

for list2 in agency_list:
    print "generating trails shapefiles"
    where_clause = "trail_type = 'Existing' AND agency = '" + list2 + "'"
    arcpy.MakeFeatureLayer_management (trails_fc, "trails_lyr")
    arcpy.SelectLayerByAttribute_management ("trails_lyr", "NEW_SELECTION", where_clause)
    output_trails = "\\" + list + "_TRAILS.shp"
    arcpy.FeatureClassToFeatureClass_conversion ("trails_lyr", output_loc, output_trails)
    print "trails shapefiles complete"


If i remove the list item 'MRCA/SMMC' the script runs fine. Otherwise, I get this error:

Message File Name   Line    Position    
    <module>    C:\Users\johndiaz\Documents\trails_app_create_shapefiles.py 36      
    FeatureClassToFeatureClass  c:\program files (x86)\arcgis\desktop10.5\ArcPy\arcpy\conversion.py 1891        
ExecuteError: ERROR 000210: Cannot create output C:\Users\johndiaz\Documents\Outerspatial_Shapefiles\\MRCA/SMMC_TRAILHEADS.shp
Failed to execute (FeatureClassToFeatureClass).

Any advice?

  • When questions are placed on hold awaiting more information from you like at gis.stackexchange.com/q/301519/115 please always edit the original question rather than re-asking the same question.
    – PolyGeo
    Nov 8, 2018 at 20:05

2 Answers 2


You cannot name a shapefile with a forward slash. You will need to add some code to check the list element, then replace the forward slash. Something like...

x = "foo/bar"
if "/" in x:

    x = x.replace("/", "_")

print x

You are trying to create a file with a forward-slash in the filename on a drive formatted with (presumably) the NTFS filesystem. That is not allowed by NTFS (or most other filesystems), slashes are forbidden characters, so you get an error. If you try creating a new text file on your machine and renaming it to "MRCA/SMMC_TRAILHEADS.shp", you'll get a similar error. Format the filename to eliminate any forbidden characters and it will work.

  • Thanks Dan! This is the problem! I will rework my script to the file name meets the file naming standards for NTFS. This has had me stumped for some time.
    – John Diaz
    Nov 8, 2018 at 16:32

Your Answer

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

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