Solved! Go to Solution.
import arcpy # create or open an existing text file f = open("c:\\data\\fc_list.txt", "a") # specify the geodatabase you want to retrieve feature classes from gdb = "c:\\data\\MyGeodatabase.gdb" # set your environment workspace arcpy.env.workspace = gdb #list all of the feature datasets within the geodatabase datasetList = arcpy.ListDatasets("*") # within each feature dataset, list the feature classes and write them to the text file for dataset in datasetList: fcList1 = arcpy.ListFeatureClasses("*","",dataset) for fc in fcList1: f.write(fc + "\n") # find all of the feature classes which do not reside within a feature dataset fcList2 = arcpy.ListFeatureClasses("*") # write the feature class names to the text file which don't reside in the feature dataset for fc in fcList2: f.write(fc + "\n")
import arcpy, os outputDir = arcpy.GetParameterAsText(0) outputName = arcpy.GetParameterAsText(1) gdb = arcpy.GetParameterAsText(2) textFile = (outputDir + os.sep + outputName + ".txt") f = open(textFile, "a") arcpy.env.workspace = gdb datasetList = arcpy.ListDatasets("*") for dataset in datasetList: fcList1 = arcpy.ListFeatureClasses("*","",dataset) for fc in fcList1: f.write(fc + "\n") fcList2 = arcpy.ListFeatureClasses("*") for fc in fcList2: f.write(fc + "\n")