Exists "C:\Program" vs exists file "C:\Program" vs exists folder "C:\Program"

I came across a bit of relevance code in a fixlet that had:

exists “C:\Program”

What it was trying to do was find a file or folder with the name C:\Program that had been accidentally created. It seems some applications don’t like it when such a file (or folder) exists…

The relevance seemed to be returning true, even on Non-Windows systems …

exists file “C:\Program”

and

exists folder "C:\Program"
Seem to be "much more discriminating…

What exactly would

exists “C:\Program” be looking for???

Any clue?

Thanks,
Bob_K

Try this:

exists "funky chicken"

This is evaluating whether the string exists, so this form should always return true.

4 Likes

This is how you would check for both a file or folder:

exists (files it; folders it) of "C:\Program"

@amelgares,

Thanks! I knew there were a bunch of Funky Chickens on our Solaris boxes!!! :wink:

@jgstew,

I’m assuming that is a little more efficient than using:

(exists file "C:\Program") OR (exists folder "C:\Program")

Bob_K

Not exactly more efficient and not really even more readable. It has the advantage of only defining the string once and using it twice, which makes it easier to change or modify or add to:

exists (files it; folders it) of ("C:\Program"; "C:\temp"; "C:\vcredist.exe")

So, that would return true if at least one of the listed items was a file or a folder that existed on the system being checked, right?

Bob_K

1 Like

Exactly. TRUE if a file or folder exists by any of those 3 paths.

1 Like

See this related example that uses the same idea, but to get a rough approximation of OS install date for all operating systems: