Search if a folder with a specific name exists or not under some folder (windows)

Hi,

I try too much but get no close result about how to find if a folder exists or not with a specific name contains “W3” under some folder of folder:

for example; folder name W3 under folder c:\inetpub\logs\logfiles.

I wiil be appreciated for any asnwer,

Best regards

If I get your question right you want to check for existence of a folder whose name contains a value, “W3” in your case. For your example try this:

(exists folder whose (name of it contains "W3") of folder "c:\inetpub\logs\logfiles") as string | "N/A"

Note that I used the pipe to deal with the case when the containing folder does not exist as you would get something like : “Error: Singular expression refers to nonexistent object.”

If instead you are just looking for a folder name inside another folder than use this simpler form:

(exists folder "W3" of folder "c:\inetpub\logs\logfiles") as string | "N/A"
1 Like

Thanks for the reply,

Although there are many servers matching, still no server comes from this relevance:

(exists folder whose (name of it contains “W3”) of folder “c:\inetpub\logs\logfiles”) as string | “N/A”

Something I did is wrong but I do not know where it is :slight_smile:

It’s hard to guess where it may be failing. Can you show a screenshot of the directory you are looking for?

A bit more info into what you are trying to do can help us help you.

  1. What do you mean by many servers matching but no server comes from this relevance ?
  2. Where/How are you running the relevance, did you use the Fixlet Debugger ?
  3. Did you try the relevance on 1 server where you know it should work and what was the result ?

Here are the screen shots

![W3|690x364](upload://l8GhxzfY2bAfixlet applicable serversjC4dcxtdfCsdOhH1.JPG)

Your relevance isn’t returning a boolean - it returns a string.

try

(exists folder whose (name of it as lowercase contains "w3") of folders "c:\inetpub\logs\logfiles")

OK, so you are using it as relevance in a Fixlet. The expected return type is boolean while the example I gave you returns a string. Change it to the following:

(exists folder whose (name of it contains "W3") of folder "c:\inetpub\logs\logfiles")

Thank you very much , it works.

Actually “c:\inetpub\logs\logfiles” works but “c:\inetpub\logs\LogFiles” did not. Capital letters are important for BigFix relevances.

Best regards

It depends upon the context

q: pathnames of folders of folder "c:\inetpub\logs"
A: c:\inetpub\logs\LogFiles
I: plural string

q: exists folder "c:\inetpub\logs\logfiles"
A: True
I: singular boolean

q: exists folder whose (name of it = "logfiles") of folder "c:\inetpub\logs"
A: False
I: singular boolean

Note that the folder name is LogFiles, but you can get different results when using different properties to do the comparision.

For Windows, because the file system is not case-sensitive, the second example above returns true.
This would not work for Linux because the file system is case-sensitive.
The third example returns false because it is comparing string values (which are case-sensitive).