I have some Shapefiles inside one Folder and for the sake of data compression I want to delete all fields from Table of Content that can be removed (that are not required)!
What I have:
What I expect:
My code that is not working:
import arcpy
import os
arcpy.env.workspace = r"C:\Temp\"
fcList = arcpy.ListFeatureClasses()
for fc in fcList:
fields = arcpy.ListFields(fc)
for field in fields:
delFlds = [field for field in fields if field != "FID" or field != "Shape"]
arcpy.DeleteField_management(fc, delFlds)
I am using Python 2.7 and ArcMap 10.4.1