Find feature class

674
1
06-03-2014 08:34 PM
PierreWeisse
New Contributor
Hello,

I work on SDE data bases.

I would list all the entities classes ending in "_OLD".
However in my database SDE I've feature classes and datasets entities.

I would like the script gives a complete list of feature classes ending in "_OLD".

Thank you for your help.
Tags (2)
0 Kudos
1 Reply
JamesCrandall
MVP Frequent Contributor
See if this helps.  I can't remember exactly where I lifted the original code from.  Probably a quick google search is where I started.


gdb = r'Database Connections\MyDBConnection.sde'
arcpy.env.workspace = gdb
featclsInDatasets = []

for fds in arcpy.ListDatasets('','feature') + ['']:
  for fc in arcpy.ListFeatureClasses('*_OLD','',fds):
     featclsInDatasets.append(os.path.join(fds, fc))

#list the featclasses in datasets
for fc in featclsInDatasets:
    print fc

#list the featClasses not in datasets
for fcmain in arcpy.ListFeatureClasses('*_OLD'):
    print fcmain




edit: ah... I think this is where I originally found the sample: http://gis.stackexchange.com/questions/5893/listing-all-feature-classes-in-file-geodatabase-includin...
0 Kudos