Apply Keyword using Apple Script?
Hi there,
Sorry for this basic question, but how do I apply one or more keywords using Apple Script? I have it working to apply a colour tag and process using a specific recipe but I would also like to apply a keyword (called "Kiosk") at the same time to the selected Variants.
It's obviously not this as it doesn't work (but am I close?)
tell thisVariant to apply keyword "kiosk"
Rest of Script (that works OK):
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application "Capture One 22"
repeat with thisVariant in (get selected variants)
tell thisVariant to set color tag to 4
process thisVariant recipe "Send to SPS"
end repeat
end tell
Thanks so much for your help!
-
I don’t have time to check deeply right now, but if memory serves correctly the supported commands are (tell variant to) “add keyword”, “delete keyword”, “get keyword” and “set keyword”
ScriptDebugger and I think also ScriptEditor have a useful “supported commands” function0 -
This is what I've found, just having trouble getting something to work to apply a keyword "kiosk" to the variant inside the script.
0 -
Funny, I'm working on a similar project :-)
It seems that Keywords are read only from Apple Script :-(
You have to create a new library first (or add to an existing one) and add the Keywords manually
0 -
If you figure out a way I'd love to see what it looks like. I'm totally new to Apple Script. Thanks!
0 -
Sorry for the delay, its been a busy week.
What has worked for me in a script I wrote for CaptureOne 12 is
Tell application “Capture One 12” to make keyword at thevariant with properties {name:theNewKWname, parent:theparent}
theNewKWname and theparent are strings. (theparent is the parent’s name)
If there is no parent the don’t include parent:theparent
theVariant is a reference to the variant as in
Tell application “Capture One 12”
set theVariantList to selected variants
repeat with thevariant in theVariantList0 -
Don't work in CO22 (it's now read only)!
0 -
Solved it. New keywords can only be made in a keyword library.
First you must make a reference to a keyword Library.
Set theKeyWordLib to first keyword library
will work.
In my case “KeywordLib1” is my keyword library of choice,
Set theKeyWordLib to keyword library “KeywordLib1”Then
Tell theKeyWordLib to make new keyword with properties {name:”test1”}Now that we have a new keyword with the desired contents it can be applied to some variants.
The making part verified on CO22. Haven’t verified the apply part yet
Then
2 -
I made a 'dirty' workaround with Exiftools (I need the information anyway):
----------------
--Script for adding FocusDistance from ExifTools to Keywords in Capture One 22
--© 2022 Alexei Russak
tell application "Capture One 22"
repeat with theVariant in (variants whose selected is true)
set picloc to the path of parent image of theVariant
set picname to the name of parent image of theVariant
set ShutterCount to do shell script "/usr/local/bin/exiftool -FocusDistance " & quoted form of picloc
try
display dialog ShutterCount with title picname buttons {"Ok", "Copy to Keywords", "Cancel"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Ok" then
--just for further purposes
set dummy to dummy + 1
else if the button_pressed is "Copy to Keywords" then
do shell script "/usr/local/bin/exiftool -Keywords+=" & quoted form of ShutterCount & " " & quoted form of picloc
reload metadata theVariant
else
exit repeat
end if
on error
exit repeat
end try
end repeat
end tell
------------
Regards
0 -
:-) ShutterCount is from a very old project - that's how errors continue :-)
0 -
Sorry to dig up an old thread, but I missed this the first time around. You can absolutely apply keywords directly with AppleScript. I have a script that's part of my scripts collection that just that. You can tell the variant to make a keyword, rather than apply one
tell theVariant to make keyword with properties {name:theCleanKeyword}
1 -
Emory Dunn would it be possible to create a script that adds keywords from scanning or something the same way your "next capture folder" script
Could you scan/enter several keywords and have it "entered" at the same time.0
Post is closed for comments.
Comments
11 comments