Open Catalog based on filename

Discussion regarding all scripting related questions
Please DO NOT post to this thread anything that is not directly related to scripting of Capture One.

Open Catalog based on filename

Postby Skids » Mon Nov 18, 2019 2:41 pm

I have recently started using Capture On12 and have followed advice and split my collection of images into several medium sized catalogs. My images are stored in the Finder in folders named after the year of capture e.g. /2019 stores this years images. I would like to be able to review these images using the Finder or a 3rd party DAM and open a selected image into Capture One for viewing and editing.

The first four characters of the image name specifies the year it was taken so also defines the parent folder. My Capture On Catalogs are also based on years e.g. "All_Images2016_2019" meaning that the year can be used to identify which catalog stores the image record.

I would like to write a script that parses the name of any image passed to it, determines which Capture One Catalog holds the image and then opens the catalog in Capture One. The icing on the cake would be to have the target image selected in some way ready for review.

Do you think that such a script is possible?

best wishes

Simon
Skids
 
Posts: 36
Joined: Wed Apr 22, 2015 2:38 pm

Re: Open Catalog based on filename

Postby Skids » Mon Nov 18, 2019 10:49 pm

I've made a start by "borrowing code found on this forum" . I am unable to test as I'm doing a new import that will take hours.

Proof of concept with hard coded variables .

Code: Select all
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set tTargetImageName to "NameOfImageToDisplay"
--tell application "Finder" to open :Users:skids:Pictures:Capture_One_Catalog.cocatalog

tell application "Capture One 12" to open POSIX file "/Users/skids/Pictures/Capture_One_Catalog.cocatalog"

tell application "Capture One 12" to tell current document
   set current collection to collection "All Images"
   set AllVariants to (get variants)
   set countOfVariants to count of AllVariants
   
   set everyImageIDList to get id of every image
   --set everyImageIDList to get name of every image
   
   repeat with v_Counter from 1 to countOfVariants
      set thisVariant to item v_Counter of AllVariants
      set searchedImage to (get parent image of thisVariant)
      set searchedImageName to (get name of searchedImage)
      
      if searchedImageName = tTargetImageName then
         set searchedImageID to (get id of searchedImage)
         select the image searchedImageID
         exit repeat
      end if
   end repeat
end tell
Skids
 
Posts: 36
Joined: Wed Apr 22, 2015 2:38 pm


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest

cron