I have a similar issue to these threads:
However, I want to search through multiple folders/directories for any feature (FC in an FD, FC in a GDB, shapefile) that has a name that matches a wildcard search (i.e. any of the above features that has a name like ABC*). I would then like to either copy the feature (if it is a feature class) or convert to a FC (if it is a SHP). Bonus if I could rename the copied feature to part of the name of it's original parent directory (i.e. a project number).
123_Folder --> contains gdb with FC "ABCDE"
456_Folder --> contains folder XYZ with shp "ABCFGHI"
789_Folder --> contains folder LKJ with GDB "KJFSL" with FD "IKESHL" with FC "ABC"
I would love to end up with a gdb that contains: 123_ABC, 456_ABC, 789_ABC, etc.
I'm guessing I need to break this down into multiple search iterations?
I am only a beginner scripter, but learn quickly. Thanks for any help!
Edit: I now have this:
import arcpy, os #Set the workspace workspace = r"C:/temp" #create list of files from directories and subdirectories for root, dirs, files in arcpy.da.Walk(workspace, datatype="FeatureClass", type="Polygon"): for name in files: if name.startswith("ABC") or name.startswith("DEF"): path = os.path.abspath(os.path.join(root, name)) print path
It works great! What I'd like to do now is convert each one to a centerpoint and append to a feature class I already have set up. However, I'd like to exclude any poly that was found in an Archive folder. That is, if the word "Archive" shows up in the path name I want to skip over it. How can I program that in Python?