AnsweredAssumed Answered

delete shapefiles starting with a certain word

Question asked by sotriant on Jun 11, 2018
Latest reply on Jun 11, 2018 by bixb0012

i want to create a script that will delete shapefiles, that exist in a number of folders, starting with a specific word i.e "points". I have created the following function but i cannot figure out how to care for the specific word. Any ideas?

 

def deleteShps(point_shp, sortedStops, Route_shp, Stops_shp, ExpStops_shp, Store_shp):
try:
   if arcpy.Exists(point_shp):
      arcpy.management.Delete(point_shp)
   if arcpy.Exists(sortedStops):
      arcpy.management.Delete(sortedStops)
   if arcpy.Exists(Route_shp):
      arcpy.management.Delete(Route_shp)
   if arcpy.Exists(Stops_shp):
      arcpy.management.Delete(Stops_shp)
   if arcpy.Exists(ExpStops_shp):
      arcpy.management.Delete(ExpStops_shp)
   if arcpy.Exists(Store_shp):
      arcpy.management.Delete(Store_shp)

Outcomes