Page 1 of 1

Copy keywords from single image

PostPosted: Thu Dec 06, 2018 8:33 pm
by NNN636547779233695174
Is there a way to copy all keywords from a single image? I am hoping to be able to do so in order to paste those keywords into a text file. I can see all the keywords on an image, I can get a different view of their hierarchy, but there doesn't seem to be a simple way to copy them with the intent to paste.

Any help is appreciated.
Thank you.

Re: Copy keywords from single image

PostPosted: Fri Dec 07, 2018 1:36 pm
by Eric Nepean
It's possible to do this with a simple AppleScript but I am don't know of any CO setting to do this. If you are interested, we need to have a short discussion on how multiple key words should be separated and how hierarchical keywords should handled and I can write such a script.

Re: Copy keywords from single image

PostPosted: Fri Dec 07, 2018 7:17 pm
by NNN636547779233695174
Thank you for your response, Eric. I really appreciate it. For what I am currently needing this for, hierarchy doesn't need to be maintained. I would like each level to be represented, but each word just needs to be separated by a comma.
Example:

Travel
-Europe
-Asia
-Mexico
-Canada

Studio
-Product
-Portrait
-Family

This could be summarized to:
travel, europe, asia, mexico, canada, studio, product, portrait, family

Re: Copy keywords from single image

PostPosted: Fri Dec 07, 2018 7:34 pm
by Eric Nepean
I will write something this weekend. It may be that if I just take the keywords in order, the order may be unexpected, e.g.
travel, studio, mexico portrait - have to see.

Re: Copy keywords from single image

PostPosted: Fri Dec 07, 2018 8:06 pm
by NNN636547779233695174
The order wouldn't matter at all. I am just needing all the keywords, parent or child, in some form that and can easily select and copy. It's a pretty simple thing that I wish I could do within C1, but it just seem possible. I tried accomplishing what I needed by exporting the image and then doing a simple Get Info on the exported file. The Info box shows me the keywords just as I need them, in a listed form, and I can select them and copy them. The only issue that keeps this from being my solution is that the Info box is limited to 2 lines. So a certain amount of keywords show and then it will say "...+7 more". So I cannot get the complete list using this method.

Long explanation, but I hope that helps describe the simplicity of what I'm going for.

Thanks Eric!

Re: Copy keywords from single image

PostPosted: Fri Dec 07, 2018 9:09 pm
by Eric Nepean
I don’t have access to my Mac right now. (but I started writing code in 1967) so let’s give this a shot ....

Edit1: it should be primary variant not selected variant
Edit 2: Fixed the quotes. Tested it, it works.
Code: Select all
tell application "Capture One 12" to tell primary variant to set theKwNameList to name of keywords
set KwNameString to ""
set kwctr to 0
set kwcount to count of theKwNameList
repeat with theKwName in theKwNameList
   set kwctr to kwctr + 1
   set KwNameString to KwNameString & theKwName
   if kwctr < kwcount then set KwNameString to KwNameString & ", "
end repeat

set the clipboard to KwNameString


If you select a variant and run this script, a list of the keyword names should end up on the OSX clipboard. This can then be pasted into a text document. It’s possible that Script Editor may complain about the double quotes, in which case replace them using script editor.

Let me know how that goes.

It should gracefully handle no keywords, but will declare an error if there is no selected variant.

Re: Copy keywords from single image

PostPosted: Sat Dec 08, 2018 1:51 am
by Eric Nepean
And here is athe final version that notifies you if you have not selected a variant, or the variant has no keywords.

Code: Select all
use AppleScript version "2.5"
use scripting additions

## if no variant is selected, "No Variant selected" is written to the clipboard
## If there are no key words, "No Keywords"  is written to the clipboard

try
   tell application "Capture One 12" to tell primary variant to set theKwNameList to name of keywords
on error
   set the clipboard to "No Variant selected - no keywords"
   display notification "No Variant selected - no keywords"
   return
end try

set KwNameString to ""
set kwctr to 0
set kwcount to count of theKwNameList

if 0 = kwcount then
   set the clipboard to "Variant has no keywords"
   display notification "Variant has no keywords"
   return
end if

repeat with theKwName in theKwNameList
   set kwctr to kwctr + 1
   set KwNameString to KwNameString & theKwName
   if kwctr < kwcount then set KwNameString to KwNameString & ", "
end repeat

set the clipboard to KwNameString

Re: Copy keywords from single image

PostPosted: Wed Dec 19, 2018 7:11 pm
by NNN636547779233695174
Eric,

I apologize for the delay in my response. I have zero experience with scripting, so it took me awhile to figure out how to implement this. But I figured it out, tested it, and it works just as you described! This works perfectly for what I need. I can't thank you enough!

Re: Copy keywords from single image

PostPosted: Tue Dec 25, 2018 9:49 pm
by Eric Nepean
NNN636547779233695174 wrote:Eric,

I apologize for the delay in my response. I have zero experience with scripting, so it took me awhile to figure out how to implement this. But I figured it out, tested it, and it works just as you described! This works perfectly for what I need. I can't thank you enough!

No problem, glad to hear you got it working.
If you had asked I would have pointed you to a write up I've done on that on the Scripting forum. :)
If you've go other scripting questions the scripting forum is a good place to ask.

I occasionally post some cool scripts there.