Find folders matching a pattern


BigFix’s lingo doesn’t support the use of wildcards, so how would I create a relevance statement looking for folder’s whose name matches a pattern?

For example: C:\Folder\Subfolder01, Subfolder02, etc…

I want to find all “Subfolders” under “Folder” that have a two-digit number in their name. Something I would regularly do with C:\Folder\Subfolder* in other platforms. The end game is to ‘rmdir /s /q’ the relevant folders.

My best attempt of "exists folder “C:\Folder\Subfolder*” is not working.


find folder inspector could be your friend:

find folder <string> of <folder> : folder

Finds the folder with the given wildcard name inside another folder. A wildcard string uses an asterisk to stand for any number of characters (incuding zero), and a question mark to stand for exactly one character. Thus A??.txt would match All.txt and AXE.txt but not all.txt or a.txt.

Plural: find folders

Be careful about using it, if the folder has a lot of sub-folders the client could take a long time to return results and also you could see more issues.

1 Like

Sweet! I’ll give this a try. Thanks!

No dice. “find folders” not defined…

You are using the inspector incorrectly.


q: folders of folder "C:\tmp\"
A: C:\tmp\nb
A: C:\tmp\TB1
A: C:\tmp\TB2
A: C:\tmp\{01250149-1489-2568-2558-567014569232}
T: 1.242 ms
I: plural folder

q: find folders "TB*" of folder "C:\tmp\"
A: C:\tmp\TB1
A: C:\tmp\TB2
T: 0.662 ms
I: plural folder
1 Like

Almost there, try this instead:

find folders "Subfolder??" of folder "C:\Folder"

Got it. Thanks!

How would the result best be fed into the
waithidden cmd /c rd {query} /s /q
though (specifically when there are multiple folders found)?

…by building a batch file with the results, concatenated with Carriage Return / Line Feed (%0a%0a)

Delete __appendfile
Appendfile {concatenation "%0d%0a" of ("rd /s /q %22" & pathname of it & "%22") of folders whose ('your query here')}
Delete cleanup.cmd
Move __appendfile cleanup.cmd
Waithidden cmd.exe /c cleanup.cmd

That sounds like a great solution!
But what does it seem I’m overlooking here?

Q:find folders "*-v*" of folder "C:\temp"
A: C:\temp\POS-v24
A: C:\temp\POS-v26
A: C:\temp\POS-v27
T: 0.621 ms

Q:concatenation "%0d%0a" of ("rd /s /q %22" & pathname of it & "%22") of folders whose (find folders "*-v*" of folder "C:\temp")
E: The operator "folders" is not defined.

STATUS: Running action...
Command failed (Relevance substitution failed) appendfile {concatenation "%0d%0a" of ("rd /s /q %22" & pathname of it & "%22") of folders whose (find folders "*-v*" of folder "C:\temp")}
Command failed (This expression contained a character which is not allowed.) appendfile {concatenation "%0d%0a" of ("rd /s /q %22" & pathname of it & "%22") of folders whose (find folders "*-v*" of folder "C:\temp")}

--- Result ---
Evaluation failed!



pathnames of find folders "*-v*" of folder "C:\temp"






Yea that gives a plural result - so you have to use a ( ) loop to deal with the results one-at-a-time

appendfile {concatenation "%0d%0a" of ("rd /s /q %22" & pathname of it & "%22") of find folders "*-v*" of folders "c:\temp"}

Beautiful, thanks as ever Jason!


I played with this a while last night but will also be trying to do something like
whose ((last 2 of pathname as integer) <28)
with that - possible?

So close…
pathnames of it whose ((last 2 of pathnames of it as integer) <28) of find folders "*-v*" of folders "c:\temp"


I can’t help feeling this error is a bit misleading…


That last one looks like maybe you split your actionscript into two lines?

It is two lines but the second begins with “wait”.

Oh, ok, the way it highlighted made me think you might have a line split between “find folders”. At first glance I don’t see anything else wrong with it but may be able to try it later.

Much appreciated!

The highlighting seems to be the Fixlet Debugger’s effort at narrowing down the problem for me.

Hello - you didn’t happen to play with this by chance did you? I’m stumped.