Get Started With AppleScript – Basics

An intro series to scripting Capture One, with Ben Liddle

Preamble

Years ago, in a warehouse in deep industrial Brooklyn, I was a digital technician on an e-commerce photo shoot struggling to stay awake. It was 3:30 in the afternoon on a crisp winter’s day, and the stylist was diligently stringing up the 80 billionth (by my estimate) crossbody’s strap of the day. The photographer was (probably) retouching his latest editorial job on his laptop in the corner. I was working with Capture One Pro 8 (iirc, maybe it was 7, honestly there wasn’t much difference for this workflow), and pulling up yet another go-by for styling reference. It was one of those shit days where you arrive on set at call time before sunrise and just know in your bones that you’re not leaving before sunset.

As an aside, if you’re reading this and you were on set that day, I don’t mean to offend. I look back fondly on those days, those mid-shoot conversations, the catering, but I think we can all agree that it wasn’t the most enthralling of experiences.
The actual “work” I was doing on that job was mostly completed in the setup day from the week earlier; after that, it was scan the barcode, create a new Capture folder, name the capture folder, reset the capture counter, set the camera to Live View, set up the proper go-by as an overlay, make sure the stylist can see the Live View, take test shots, check focus, color tag images, process, comp in Photoshop, hit Chronosync, rinse, repeat ad nauseum.

If you’ve worked e-commerce, you probably had a similar flow.

I did this for years and years to pay rent, in between the “fun” jobs that filled up my passport pages. I figured there had to be a better way; a way to be lazier, yet not fuck up. Just do less. Fast forward a few years, ~13 versions (Capture One 20-Capture One 7=Capture One 13, the math checks out, fight me), and there’s little from that day on set that can’t be automated. Well, afaik you can’t automate rigging a crossbody strap to match the 799,999,999,999 previous, but I digress. My heart goes out to you still, stylist.

Heads up!

I’ll be using Capture One 20, since it’s known to be the most scriptable of the Capture One versions. If you haven’t tried Capture One 20, you can get a trial at https://www.captureone.com/en.
If you’ve made it this far and are on Windows, I’m afraid I can’t help you achieve peak lazy. As of this writing, only Capture One on macOS (and OSX, if you’re feeling retro) can be automated via scripts.

Capture One can run .scpt files in AppleScript (aka AS), Javascript for Automation (aka JXA), and AppleScript-ObjC. Frankly, I’m most comfortable in AS, have fairly extensive experience with JXA, but little/none with AS-ObjC. There’s obviously syntactical differences between the three languages, and for the purpose of these articles, I’ll be dealing mostly with AS.

For the rest of this story, I’ll be doing a bit of beginner’s intro to AppleScript and Capture One. If you have experience with AS, I suggest checking out the next post in this series: Selecting Variants and Images

Hello, World

As an introduction, we’re going to write a basic Hello, World to illustrate running scripts in Capture One. There are many, many IDEs (Integrated Development Environment, basically software for writing code) out there. For AS specifically, I’ve used a few:

Script Editor: already bundled with macOS. Simple. I’d say use this to get your feet wet, and for the first few stories I’ll be screen-shotting from this.

Atom (https://atom.io/): Open source text editor that can do just about… anything? You’ll need a few extensions to get it to parse/compile/execute AS, but it’s pretty.

Script Debugger (https://latenightsw.com/): My preference. Extremely verbose and powerful. Not free though, still a bargain at any price if you end up creating any complex automations, especially if they involve multiple applications.

Open up your IDE and create a new script named hello world.scpt.
Here’s the code we’ll be adding. Note: comments in AS are denoted by starting with — . Comments are blocks of the code that aren’t actually run and are used to explain what’s going on.

Press cmd+k to compile the script. If it compiles correctly, you’ll get indentations, syntax-based highlighting, the whole works. If not, you’ve made an error.

Hit the Run button to run the script.

Congrats. That’s AppleScript 101. You can find more on the basics here:

  • Mac Automation Scripting Guide (from Apple)
  • Introduction to AppleScript Language Guide (from Apple’s documentation archive)
  • AppleScript Beginner’s Tutorial (from macosxautomation.com)
  • Hello (name of document)

    Let’s start working with Capture One directly to get the name of the document; your session or catalog database file:

    It’s worth pointing out here that the above code has the display dialog verb within the tell current document block. Because it’s nested, the current document is the one calling the display dialog. Any further interaction with the current document is blocked until that dialog is cleared (one of the buttons is pressed). This code appears to result in the same actions, but since display dialog is outside of the tell application and current document blocks, it’s the OS that’s calling it:

    Because we stored the document’s name in the variable doc_name, we can extract that data and use it anywhere we like!

    That’s a good enough intro. In the next story, we’re diving into some more complex workflows.

    Ben Liddle is a data manager in Colorado who automates the shit out of the first half of the work/life balance so the second half can be more fun.

    One Comment on “Get Started With AppleScript – Basics

    1. Pingback: Get Started With AppleScript – Conditional Processing pt1 – SHOOT MACHINE

    Leave a Reply

    %d bloggers like this: