SDK: catalog:findPhotos() - how to sort photos with user order?

New Here ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

I need to process photos of a collection or a folder in sequence of their manually arranged "User Order".

catalog:findPhotos() uses a sort argument which is documented as

  • sort: (optional, string) How matching photos are sorted. One of "captureTime" (the default), "fileName", "extension".

This is only a subset of the sort options available in the application:

Siegfried21965884bfck_0-1650992141281.png

Trying to use assumed argument values, I found that the following options work:

  • sort = "addedOrder"
  • sort = "rating"
  • sort = "pick"
  • sort = "labelColor"

What did not work was:

  • sort = "editTime"
  • sort = "editCount"
  • sort = "labelText"
  • sort = "fileType"
  • sort = "aspectRatio"
  • sort = "userOrder"

 

Assuming that all sort options, available in the application, should also work for the SDK, what would be the parameter values for the missing options, especially for sorting with User Order?

 

TOPICS
SDK

Views

64

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
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 26, 2022 Apr 26, 2022
"what would be the parameter values for the missing options, especially for sorting with User Order?" The user-defined order, Custom Order in the UI, is specific to individual folders and collections, and you can't access that order using catalog:findPhotos (), folder:getPhotos(), or collection:getPhotos().   The best you can do is to get the order of the photos of the currently displayed source(s) in Library gridview, using a song-and-dance routine: Save the current selection with catalog:getTa...

Likes

Translate

Translate
LEGEND ,
Apr 26, 2022 Apr 26, 2022

Copy link to clipboard

Copied

"what would be the parameter values for the missing options, especially for sorting with User Order?"

 

The user-defined order, Custom Order in the UI, is specific to individual folders and collections, and you can't access that order using catalog:findPhotos (), folder:getPhotos(), or collection:getPhotos().  

 

The best you can do is to get the order of the photos of the currently displayed source(s) in Library gridview, using a song-and-dance routine: Save the current selection with catalog:getTargetPhotos(). Deselect all the photos with LrSelection.selectNone(). Now, catalog:getTargetPhotos() returns all the photos displayed in grid view, in the order they are currently displayed. Finally, restore the original selection with catalog:setSelectedPhotos().

 

If you want to get the Custom Order of a folder or collection that's not currently active, you could extend the song-and-dance by calling catalog:getActiveSources(), then catalog:setActiveSources() to set the folder or collection as the current source, then get its custom order using above, then restore the original sources with catalog:getActiveSources(). Beware that catalog:get/setActiveSources() is a little fragile and has some broken edge cases, sometimes it doesn't take effect immediately.

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
community guidelines
New Here ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

Thanks a lot.

... a little bit complicated but it works.

 

However, now that I can get the photos in the intended order, I will nevertheless not be able to complete my intended usecase:

I have thousands of photos, scanned from slides and negatives from the pre-digital era, for which the capture time is the scan time from the scanner and not the time when the photos were taken.

After grouping in collections and manual ordering, I wanted to manually set the capture time for the first photo to approximately the correct time. Then, for the remainder, the capture time should be programatically incremented so that at least the order is correct.

The application function to modify the capture time does not allow to do this. For multiple selected photos it just applies the time shift for the primary selected photo to the rest, which does not modify the order.

 

However, I learned that there seems to be no possibility to programmatically modify the capture time 
(Gelöst: Re: Edit capture time via SDK - Adobe Support Community - 10180503)

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
community guidelines
LEGEND ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

LATEST

"I wanted to manually set the capture time for the first photo to approximately the correct time. Then, for the remainder, the capture time should be programatically incremented so that at least the order is correct.

The application function to modify the capture time does not allow to do this. For multiple selected photos it just applies the time shift for the primary selected photo to the rest, which does not modify the order."

 

Yeah, those are important missing features from both the SDK and the Metadata > Edit Capture Time command. 

 

Once you've got your sort order manually set, you could use the Capture Time To Exif plugin to set the times in the way you'd like.   It uses the Exiftool utility to set a cataloged photo's capture time.  I've managed the capture times of my photos using my own plugin that also uses Exiftool in a similar way.

 

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
community guidelines