At ArcGIS Desktop 10.7.1, I have created a simple tool that iterates recursively through a folder, selecting all polygon feature types.

The input folder will always be two located two folders above the location of the tool. Accordingly, I have incorporated %currentworkspace%\..\..\SOME_INPUT_FOLDER as the iterator's input, as shown below. Note that in my example I have hard-coded the input folder's name, SAMPLE_PROJECT.

This model works correctly.

enter image description here


I need to replace the hard-coded folder name with a wildcard, so that the model will run no matter the name of the input folder.

I have used both * . * and * as wildcards for the input folder name (see below). Both result in errors that scroll by too fast to read (although it think they say something about an invalid input). I have to kill Arc with the task manager to stop the scrolling errors.

enter image description here

My question:

How do I incorporate a wildcard folder name?

  • Never have seen bounty with +500 =)
    – Taras
    May 12, 2020 at 17:49
  • Lucky you!!!!!!
    – Stu Smith
    May 12, 2020 at 22:15
  • 1
    Are you trying to iterate through all folders that are two folders above the tool, or just through a single folder of unknown name? (That is, there may be multiple folders there, but you only want to iterate within one of them.) If the first case, then I think you really are trying to iterate twice (once through folders, then through polygons within folders.) In the second case, I believe @Hornbydd is right that even if your use of wildcards would resolve to a single folder, the method is not supported. (You're effectively specifying an array of one element when a single item is needed.)
    – gspontak
    May 13, 2020 at 16:28

3 Answers 3


I don't believe you can have a "wildcard" placeholder for a folder as the iterator requires a valid workspace and a wildcard is not a valid workspace.

Also I think your logic is flawed, the iterator requires a single workspace, a wildcard would suggest multiple choices, so what if you go up two folders into a folder which has 1,000,000 folders in it? Which is it? For that reason alone it makes no sense what you are asking.

The only modelbuilder solution that returns a single valid workspace is to expose the workspace parameter as a parameter and the user must select it.

  • 2
    Based on this explanation of the problem (thank you, I wasn't understanding from the question) - a Python script would be the way to go if you want to start handling multiple workspaces and doing so recursively.
    – KHibma
    May 13, 2020 at 11:44

Have you taken a look at the Iterate Files or Iterate Workspaces iterators? enter image description here enter image description here


I don't completely understand the link between the problem and the question.

For me, if you want a model that works when you want to use it on different folder, then you should simply set the folder name as a parameter. You know how to define an input as a parameter, but for the sake of completeness one has to right click on the ellips and chose "model parameter". When you run your model, you will have athe possibility to select any (single) workspace.

If your problem is to run a process on all the files of a group of folders in model builder, you need two iterators WHICH IS (currently?) NOT possible. On the other hand, a wild card generate a list, and workspace name must be a string.

There are however two workarounds:

  • first, you can use a Python script. If you are not familiar with Python, export your model as a Python script then modify it to add a loop. There are several modules to do that (just check stack exchange), but personnaly I use glob. This would look like this:
import arcpy, glob

myfiles = glob.glob("/path/with/some/*/wildcart*/*/*.shp")
for files_in in myfiles:
    arcpy.do_some_action(files_in, files_in[:-4]+"out.shp") #here I rename the output file based on the input file name by removing the

last 4 characters (.shp) and adding (out.shp) instead

The second workaround if you prefer not to use Python is to set your workspace as a parameter of your model, close your model and run it as a batch (right click on the model). This is not a automated wild card as you will need to semi-manually enter all the workspace paths, but then you can launch it once and wait until everything is done.

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.