Page 1 of 1

Script to create a project / album / smart album structure

PostPosted: Fri May 25, 2018 10:50 pm
by KevinMSmith
Hi —

I apologize if this has been asked/answered, but I did a search and couldn't find anything...

When I process, my workflow has me create a new Project with the name of the shoot and then add an "All" album. I then add smart albums (no color, red, green) and add the imported images to the "all" album.

Adding this structure each time is kind of tedious. Is there an easier way? Does anyone have a script that can accomplish something like this?

Any advice is appreciated!

Re: Script to create a project / album / smart album structu

PostPosted: Sun May 27, 2018 4:08 am
by Eric Nepean
I decided that I wanted a script like this too. Here it is; instructions are at the top.

Because AppleScript cannot directly access the the "Recent Imports" folder, the user must select the desired folder, and optionally select the images to be imported.

The script will import images from any collection the user selects.

Code: Select all
## Version 1
## The user must start by selecting the collection to import from
## If no variants are selected, then all the variants in the collection are imported
## if the collection is empty (e.g. by selecting Recent Imports, instead of one of the subcollections) then no variants are imported
## A new Project is created, there is a dialog for the user to enter the name
## Inside the Project are an Album "All" and several Smart Albums

tell application "Capture One 11" to set countVariants to count of selected variants
if (countVariants > 0) then
   set isSelection to true
   set hasVariants to true
   tell application "Capture One 11" to tell current document to set nameCurrentCollection to name of current collection
   set SelectionDescription to (countVariants as text) & " Selected Variants in \"" & nameCurrentCollection & "\""
else
   tell application "Capture One 11" to set countVariants to count of every variant
   set isSelection to false
   if countVariants > 0 then
      set hasVariants to true
      tell application "Capture One 11" to tell current document to set nameCurrentCollection to name of current collection
      set SelectionDescription to (countVariants as text) & " Variants in \"" & nameCurrentCollection & "\""
   else
      set hasVariants to false
      set nameCurrentCollection to "NotFound"
      set SelectionDescription to "No Variants"
   end if
end if


set getShootNameSuccess to false
set ExplanationText to ""
repeat while not getShootNameSuccess
   try
      set dialogMessage to ExplanationText & " Enter Name of the Shoot (Importing " & SelectionDescription & ")"
      set theShootName to text returned of (display dialog dialogMessage default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue")
   on error errorMessage number errorNumber
      if errorNumber ≠ -128 then
         error ("Script Error: " & errorMessage & " #" & errorNumber & " during Name of Shoot Entry")
      else
         error ("User Cancelled the Script at Name of Shoot Entry")
      end if
   end try
   
   tell application "Capture One 11" to tell current document to set ShootNameList to every collection whose name is theShootName
   if 0 = (count of ShootNameList) then
      set getShootNameSuccess to true
   else
      set ExplanationText to "A collection named \"" & theShootName & "\" already exists! Try again. "
   end if
end repeat

set saNoRules to "<?xml version=\"1.0\" encoding=\"UTF-8\"?><MatchOperator Kind=\"AND\"></MatchOperator>"
set saRedTagRules to "<?xml version=\"1.0\" encoding=\"UTF-8\"?><MatchOperator Kind=\"AND\"><MatchOperator Kind=\"AND\"><Condition Enabled=\"YES\"><Key>IB_S_BASIC_URGENCY</Key><Operator>0</Operator><Criterion>1</Criterion></Condition></MatchOperator></MatchOperator>"
set saGreenTagRules to "<?xml version=\"1.0\" encoding=\"UTF-8\"?><MatchOperator Kind=\"AND\"><MatchOperator Kind=\"AND\"><Condition Enabled=\"YES\"><Key>IB_S_BASIC_URGENCY</Key><Operator>0</Operator><Criterion>4</Criterion></Condition></MatchOperator></MatchOperator>"
set saNoColorTagRules to "<?xml version=\"1.0\" encoding=\"UTF-8\"?><MatchOperator Kind=\"AND\"><MatchOperator Kind=\"AND\"><Condition Enabled=\"YES\"><Key>IB_S_BASIC_URGENCY</Key><Operator>0</Operator><Criterion>0</Criterion></Condition></MatchOperator></MatchOperator>"

tell application "Capture One 11"
   tell current document
      set theNewProject to make new collection with properties {kind:project, name:theShootName}
      set theAllAlbum to make new collection at theNewProject with properties {kind:album, name:"All"}
      set theNoColorTagAlbum to make new collection at theNewProject with properties {kind:smart album, name:"NoColorTag", rules:saNoColorTagRules}
      set theRedTagAlbum to make new collection at theNewProject with properties {kind:smart album, name:"RedTag", rules:saRedTagRules}
      set theGreenTagAlbum to make new collection at theNewProject with properties {kind:smart album, name:"GreenTag", rules:saGreenTagRules}
      log (get name of current collection)
   end tell
   if hasVariants then
      if isSelection then
         add inside theAllAlbum variants selected variants
      else
         add inside theAllAlbum variants every variant
      end if
   end if
end tell

Re: Script to create a project / album / smart album structu

PostPosted: Sun May 27, 2018 11:49 am
by WPNL
Maybe you can create a session with all smart folders and such, delete all photos and then copy this session folder as a template each following session?

Re: Script to create a project / album / smart album structu

PostPosted: Mon May 28, 2018 3:11 pm
by Jim_DK
I could proffer a plan b:

If you were to automate the collection creation, select the "all" album, then run import you can have the import reference the result in "selected album", negating the need to move them after import.

Might be a different approach to your current workflow of having images in the catalog first, but it circumvents the issue of moving them after import from Recents.

Re: Script to create a project / album / smart album structu

PostPosted: Mon May 28, 2018 3:12 pm
by Eric Nepean
WPNL wrote:Maybe you can create a session with all smart folders and such, delete all photos and then copy this session folder as a template each following session?

Kevin is asking support for setting up 3 smart albums, an album and a project. This copying idea here won't help him much because in a session because you can't copy in smart albums - you can make a session template with smart albums, but you can only use it when creating the session.

In any case the Kevin wants something to support his existing catalog workflow, switching to sessions will actually change his workflow considerably.

You can, as some else has mentioned in another forum, create a template catalog with the right set set of proejects, albums and smart albums, and import this into the working catalog, and this may be easier for those wishing to avoid AppleScript.

However the Applescript above creates all the smart albums and other collections and imports the images in one operation, so it is less trouble if you don't mind running an Applescript.