Hi Mick,In the script below I put a list to count fc in dataset. If there are no fc in the dataset, you can delete it. I also append a check if fc in dataset is empty or not.See script:
import arcpy
from arcpy import env
# Sets the workspace
env.workspace = r"L:\TEMP\test_Database_working.gdb"
# lists all feature classes in the workspace (geodatabase)
listFCs = arcpy.ListFeatureClasses("*")
# lists all feature datasets in the workspace (geodatabase)
listFDs = arcpy.ListDatasets("*")
# loops through the Feature Class list and deletes any with 0 features
for fc in listFCs:
count1 = str(arcpy.GetCount_management(fc))
if count1 == "0":
arcpy.Delete_management(fc)
# loops through the Feature Dataset list and deletes any with 0 feature classes
# this part contains errors but shows what I'm attempting to acheive
for dataset in listFDs:
count = 0
for fc in arcpy.ListFeatureClasses("*", "", dataset):
count2 = str(arcpy.GetCount_management(fc))
if count2 == "0":
arcpy.Delete_management(fc)
else:
count +=1
if count == 0:
print "Delete dataset: " + dataset
arcpy.Delete_management(dataset)
print "End process"
Hope this help,Best regards,Fred