I have a project folder with many many folders within that. Some of these child folders contain a Esri .gdb file geodatabase. I want to list all the feature classes that are inside the GDBs that have AOI (Area of Interest) as a prefix.
I've tried the following:
import sys
from pathlib import Path
import arcpy
# -------------- FUNCTIONS --------------------
def searching_all_files(directory):
file_list = []
for x in directory.iterdir():
if x.is_dir():
if (x.suffix == '.gdb'):
arcpy.env.workspace = str(x)
for f in arcpy.ListFeatureClasses( "AOI*" , "Polygon" ):
file_list.append(f)
else:
file_list.extend(searching_all_files(x))
return file_list
# -------------- INIT --------------------
folder_path = r'C:\Projects'
folder_path = Path(folder_path)
list_of_files = searching_all_files(folder_path)
print(list_of_files)
This code is not listing the features, after many trials, I couldn't figure out what I've missed. Could someone give a hint how to reach that?
arcpy.da.Walk
- desktop.arcgis.com/en/arcmap/10.5/analyze/arcpy-data-access/… – user2856 Sep 3 '20 at 12:28