Highlighted

catalog:findPhotos where filename == "file name" returns all images with "file" and "name"

Jan 08, 2020

Copy link to clipboard

Copied

Using Lightroom 9.1 and doing a search using catalog:findPhotos setup as 

 

 

local imagesearch = {}

imagesearch["criteria"] = "filename"
imagesearch["operation"] = "=="
imagesearch["value"] = fullName
table.insert(search, imagesearch)

local photos = catalog:findPhotos({searchDesc = search})

 

 

Where full name is "Nichols_Taylor 11-2019-07033.CR2" the following photo filenames are returned

"Nichols_Taylor 11-2019-07058.ARW", "Nichols_Taylor 11-2019-07057.ARW" ...

It appears the space in the filename is breaking the search and doing an "any" search instead of "=="

 

Has something changed, or have I set up the search incorrectly. I am trying to do an exact match on a filename

Topics

SDK

Views

131

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

catalog:findPhotos where filename == "file name" returns all images with "file" and "name"

Jan 08, 2020

Copy link to clipboard

Copied

Using Lightroom 9.1 and doing a search using catalog:findPhotos setup as 

 

 

local imagesearch = {}

imagesearch["criteria"] = "filename"
imagesearch["operation"] = "=="
imagesearch["value"] = fullName
table.insert(search, imagesearch)

local photos = catalog:findPhotos({searchDesc = search})

 

 

Where full name is "Nichols_Taylor 11-2019-07033.CR2" the following photo filenames are returned

"Nichols_Taylor 11-2019-07058.ARW", "Nichols_Taylor 11-2019-07057.ARW" ...

It appears the space in the filename is breaking the search and doing an "any" search instead of "=="

 

Has something changed, or have I set up the search incorrectly. I am trying to do an exact match on a filename

Topics

SDK

Views

132

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 08, 2020

Copy link to clipboard

Copied

Escaping spaces with "\\ " seemed to fix it up

 

imagesearch["value"] = fullName:gsub(" ","\\ ")

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jan 08, 2020

Copy link to clipboard

Copied

[This post contains embedded images that don't appear in email. View the post in your Web browser to see the images.]

 

Hmm, escaping spaces isn't documented, and I don't think it works. For example, consider the incorrect results returned in this example:

 

Screen Shot 2020-01-08 at 3.34.43 PM.png

In general, I don't there is any way to exact match on filename.  The SDK documentation for catalog:findPhotos() says about "operation":

 

Screen Shot 2020-01-08 at 3.37.03 PM.png

 

The string-valued criteria that support exact match are labeled as such, e.g.

 

Screen Shot 2020-01-08 at 3.38.49 PM.png

"filename" is not so labeled:

 

Screen Shot 2020-01-08 at 3.41.17 PM.png

 

To do reasonably efficient exact matches on filename or any field that doesn't support exact match, you can do what my Any Filter plugin does: Use the operator "contains all" and then iterate through the results, eliminating any that aren't exactly equal to the search string.

 

[Use the reply button under the first post to ensure replies sort properly.]

 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Jan 08, 2020

Copy link to clipboard

Copied

[This post contains embedded images that don't appear in email. View the post in your Web browser to see the images.]

 

Also, you code fragement isn't constructing "searchDesc" quite correctly -- it builds a one-element array of criteria:

 

Untitled.png

I think it's an accident that works. The correct (and more concise) way to build that search:

 

catalog:findPhotos {searchDesc = {
    criteria = "filename", operation = "==", value = fullName}}

 

[Use the reply button under the first post to ensure replies sort properly.]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Graham24 LATEST
Jan 08, 2020

Copy link to clipboard

Copied

Hi John,

Thanks for the reply, my knowledge of lua is very limited and I'm only maintaining the code. I will try your suggestion with parsing the results after using contains all.

 

Cheers

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...