On May 19 Digital Transitions is will host a free webinar titled “DT Coding Series, Part 3: Getting Started with AppleScript for Capture One“.
Capture One‘s profile as a Photo Editor and Digital Asset Manager has been increasing for several years. Unlike some of its competitors, Capture One offers rich AppleScript support.
As an added bonus, we are offering a 20% discount on Script Debugger 7 for those who participate in this webinar. What do you have to loose? You get to learn about Capture One and you get a rare opportunity to save on a new Script Debugger 7 license.
Here is a brief taste of the training Digital Transitions offers for those wanting to take full advantage of AppleScript and Script Debugger with Capture One.
Why we use AppleScript
DT sells, supports, and does training for all versions of Capture One; we use Script Debugger to write and test AppleScript that we use to improve the workflows of our Capture One clientele. We also use and recommend Script Debugger to those clients when we train them to write their own Applescripts. One of the most common uses of scripting (of any kind) is to automate time-consuming and repetitive manual tasks, and one of the biggest advantages of the AppleScript is the ease with which you can interact with applications. That makes AppleScript the best choice to automate tasks that would otherwise be accomplished with button pushes and data entry inside of Capture One.
As you’d expect, there are a large variety of tasks that AppleScript can solve in Capture One, including various forms of data entry, data extraction, image adjustments, image processing, camera control and more. In this article we’ll cover three examples:
A Single Line of Code (or 3)
Capture One allows the user to add/edit metadata associated with a given image. For example, Content Description is a field where many users place vital information about the content of the image such as the SKU of the product shown, the name of the model, or a description of a location. Such users may want to quickly check that every image from a shoot has a Content Description entered, and none have been accidentally left blank. Capture One allows you to organize and filter images in a large variety of ways (rating, color tag) in a single click, but those methods are not easily* applied to Content Description. Using Script Debugger we can write a one line script that applies a red tag to any image that has an empty Content Description.
tell application "Capture One 20" to set color tag of (variants whose content description is "") to 1
Now, technically it shouldn’t really be a single line of code. We’ve indulged our desire to reduce the length of the code in a way that actually makes it harder to read and understand. So expanding this out to a more standard phrasing of AppleScript this code looks like this:
tell application "Capture One 20"
set color tag of (variants whose content description is "") to 1
end tell
Still, whether written as a single line of code, or three lines of code, it can save a lot of time. Many companies/users that use metadata in a Capture One workflow spend hours every week manually entering that metadata and then doing QC to make sure the metadata was entered correctly. So a script of only a line or three is great ROI for such users.
Sidebar – Loading the Script into Capture One
We don’t want to have to find and open this script in Script Debugger, and then push play, each time we want to access this functionality. So inside of Capture One we can select Scripts, Open Scripts Folder, which is a shortcut to accessing /Users/[your user]/Scripts/Capture One/. By dropping our script into this location we can easily run it from the Scripts menu in Capture One. You can even bind a keyboard shortcut to that using Mac OS Preferences (see our article here for more details).
Adding Repeats and If Statements
Instead of checking for empty content description, let’s say we want to store the as-captured raw file name in the Content Description prior to renaming a bunch of raw files (e.g. you’ve provided a preview of the shoot to a client using the in-camera naming and now want to rename the files, but want to maintain the ability to easily find a file based on its old name).
That only requires a few more lines of code. Because we don’t want to set all the files to have the same (static) content Description we can’t do this in a single command issued to all variants at once. Instead we need to repeat the command for each variant.
tell application "Capture One 20"
repeat with v in variants
set content headline of v to name of v
end repeat
end tell
This script applies the name of each variant to that variant’s content headline. But the use of “variants” without further context means that all variants of the currently selected collection (e.g. the current folder or album) will be affected, and some of those variants may already have a content headline. So we probably want to check if there is a content headline there already, so we avoid accidentally overwriting it. If there is already a content headline, we can change the color tag of the file to red so that it’s easy to see we have to decide what to do about that file.
tell application "Capture One 20"
repeat with v in variants
if content headline of v is not "" then
set content headline of v to name of v
else
set color tag to 1
end if
end repeat
end tell
Copying Names of Variants to Clipboard
As a final example let’s consider getting file selections into and out of Capture One. A built-in feature allows Capture One to Select By Filenamelist; this allows you to take an external list of file names (e.g. a list from a client email) and translate it into a selection inside Capture One. But the opposite process, taking a selection in Capture One, and translating it externally (e.g. into an email to a client), is not easily possible using native Capture One features. So let’s try our hand at scripting…
set textBuilder to ""
-- get list of selected images
tell application "Capture One 20"
repeat with theVariant in (variants whose selected is true)
set theImageName to the name of parent image of theVariant
set textBuilder to textBuilder & theImageName & return
end repeat
end tell
set the clipboard to textBuilder
Here we looping over each variant and adding the name of that variant to a running list of file names, and then setting the clipboard to to that list. Alternatively, we can pull a list of all filenames in one command, and using some AppleScript text manipulation tricks we can reduce that down to.
tell application "Capture One 20"
set AppleScript's text item delimiters to return
set filesnames_as_list to name of variants whose selected is true
set the clipboard to (filesnames_as_list as string)
end tell
Note before you start making changes to the text-item delimiters (as in the script above) you should read up on the best practice of changing them back to their previous value; a good tutorial on this is here.
Getting more Advanced
Of course the difficulty of the above is entirely dependent on whether or not you have a background in computer programming. If you don’t then you may already be scratching your head a bit. If you do have coding experience then all of the examples below would be considered very introductory level scripts. But far more complex tasks can be achieved by AppleScript, especially by using Script Debugger. For example the backbone of the DT TimeLapse Editor is ~3000 lines of AppleScript, developed in Script Debugger. That is a full fledged applet with a user interface that allows the user to interact images in Capture One as a time-lapse sequence, executing tasks such as deflickering, ramps, or pans.
On May 19, we will be hosting a free webinar titled “DT Coding Series, Part 3: Getting Started with AppleScript for Capture One” which you can sign up for here. We’ll also have a more advanced class on this topic later this year (date TBD). During that class we will, of course, be using Script Debugger.
Why We Use Script Debugger
AppleScript can be written in Script Editor, free and pre-installed on every Mac. So why do we pay for Script Debugger – we are a normal paid customer, and have not received any compensation for this post? Simple: time is money and Script Debugger saves us tons of time (and headaches). Using Script Editor is a lot like using Notepad to write business documents; it works, but it’s very limiting. Script Debugger is far more powerful and its features make it faster and easier for us to write code. Also, as any programmer will tell you, most of “coding” is not in writing the first draft, but in finding the bugs in your code, and here Script Debugger is infinitely more useful than Script Editor. It provides a proper Debugging mode that lets you step line by line through the code, observing the state of variables and objects along the way. Simply put, we would have gladly paid far more than Script Debugger is sold for; it’s been worth every penny and then some.
*You can create a smart album, but that can only be based on the entire session, including all subfolders. That’s problematic in a workflow where a large number of images are organized into individual capture subfolders, and metadata entry and QC are done one folder at a time. It also requires several clicks more than the scripted solution.