Deleting shapefile using ArcPy

arcpydeleteshapefile

I'm running an automated process that outputs shapefiles. However, there are these types of files that are not useful, they are garbage, so it is necessary for me to delete them.

I know that in Python the following function deletes only one file:

import os
os.remove()

However, a shapefile is more than a single file (.shx, .dbf, .prj, .cpg).

Using ArcPy, is there a way to delete all the files of a "shapefile"?

Best Answer

To elaborate slightly on @Vince's comment, use arcpy.Delete_management("C:/path/to/shapefile.shp") -- the files with other extensions will be automatically removed as well.