List All files with given text

How can I get the following relevance to list all of the files that meet the criteria. This statement returns: “Error: Singular expression refers to non-unique object.”

following text of first “=” of variables whose (it contains “xxx.com”) of (find files “*.url” of (descendant folders of folder “c:\users”))

Please note the error I encountered when using find files on a system.

I couldn’t find a .url file that is formatted like an .ini file so I had to improvise but I think the answer to your problem is to just pluralize both “text” and “first” in your relevance string:

following texts of firsts "=" of variables whose (it contains "xxx.com") of (find files "*.url" of (descendant folders of folder "c:\users"))

If that doesn’t work – could you post example contents of a .url file configured with variables in it?

Wow! That worked. I had tried texts, but not texts of firsts.

I would really like to limit the query to just the desktop. I will try:

((descendant folders of folder “c:\users”) whose (it as lowercase contains “desktop” as lowercase)

1 Like

This should work:

descendants of folders "desktop" of folders of folder "C:\users"

All of this should come with a standard warning that you can easily grind the client to a halt if the client has a lot of content on their desktop. If someone has a computer backup or something the user’s desktop could easily have 50,000 folders on it with who knows how many shortcuts and misc content

Searching with relevance is expensive so use it carefully.

1 Like

Right now I am just using it for a one time analysis.

Darn… that broke it

following texts of firsts “=” of variables whose (it contains “xxx.com”) of (find files “*.url” of (descendants of folders “desktop” of folders of folder “C:\users”))

I am getting the error: The property ‘find files of ’ is not defined

try replacing “descendants of” with “descendant folders of”

That didn’t work.

following texts of firsts “=” of variables whose (it contains “apriabpm.apria.com”) of (find files “*.url” of (descendant folders of “desktop” of folders of folder “C:\users”))

You forgot a folder!

following texts of firsts “=” of variables whose (it contains “apriabpm.apria.com”) of (find files “*.url” of (descendant folders of folder “desktop” of folders of folder “C:\users”))

Now I am getting this: Error: Singular expression refers to non-unique object.

Really calling me out on my bad relevance tonight! :smile:

Try this:
following texts of firsts “=” of variables whose (it contains “apriabpm.apria.com”) of (find files “*.url” of (descendant folders of folders “desktop” of folders of folder “C:\users”))

That only finds one instance and then stops. It is not finding all that it should.

descendants whose(name of it as lowercase ends with ".url") of folders "desktop" of folders of folder "C:\users"

You don’t use find files with descendants. It is one or the other.

@mbartosh
Figured it out! It skips the links at the root of the desktop folder.

(descendant folders of it; it) of folders "desktop" of folders of folder "C:\users"

So…

following texts of firsts "=" of variables whose (it contains "apriabpm.apria.com") of (find files "*.url" of ((descendant folders of it; it) of folders "desktop" of folders of folder "C:\users"))

@jgstew
Well, we aren’t really using find files with descendants we are using find files with descendant folders.

Using find files with descendant folders is significantly faster on my machine than using a whose it on descendants…

Q: (find files "*.url" of (descendant folders of folders "desktop" of folders of folder "C:\users"))
A: ....
T: 24.027 ms

Q: descendants whose (name of it as lowercase ends with ".url") of folders "desktop" of folders of folder "C:\users"
A: .......
T: 133.999 ms

I imagine that the find files is done in native code and is thus optimized while the whose it clause requires the work to be done in relevance and isn’t as optimized.

Here are the timings depending on the total number of files being searched over:

Find Files:
79 - 17ms
870 - 23.5ms
1660 - 30ms
4800 - 40ms

Descendants:
79 - 25ms
870 - 130.9ms
1660 - 590ms
4800 - 1200ms

2 Likes

That is interesting. Find files is much more specific, and probably native as you mention.

Thank you guys very much. This was very helpful. Both of you should collaborate on a book on relevance code.

2 Likes