I'm using the Feature Class iterator in an ArcGIS Pro ModelBuilder model to iterate over all feature classes with a name that start with (eg) "blah".

I can make this work for our enterprise geodatabase using the wildcard: *.blah*

I can make this work for file geodatabases using the wildcard: blah*

Of course, the "*." is required for enterprise geodatabases (at least with MS SQL), because the feature classes are fully qualified with the database name and schema/owner name.

However, I cannot find a way to make this work reliably for both situations using the same iterator wildcard. If use the wildcard, *blah*, it not only finds all feature classes that start with "blah", but of course it also finds some feature classes with "blah" elsewhere in their names (which I do NOT want).

Is there any way to iterate over feature classes where the name starts with a particular string that works for both file geodatabases AND for enterprise geodatabases?

1 Answer 1


As a workaround, you could use an Calculate Value tool to check the workspace name.


The expression I am using here simply checks for ".sde" in the path:


Expression: checkName(r"%Workspace%")

Code Block:

def checkName(w):
   import os
   n = os.path.basename(w)
   if ".sde" in n:
      return "*.blah*"
      return "blah*"

If the Workspace is an enterprise geodatabase, then the wildcard value is set with the .blah value. Likewise, if it's not, it uses the blah* value.

  • 1
    That's a reasonable suggestion. I guess, similarly, you could use something like if '.' in arcpy.ListFeatureClasses()[0]. Oct 24, 2023 at 22:09
  • The only thing is you'd have to set a workspace in the snippet in order to list feature classes. However, checking for a '.' in the n variable would also work.
    – evv_gis
    Oct 25, 2023 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.