Skip to main content

⚠️ Please note that this topic or post has been archived. The information contained here may no longer be accurate or up-to-date. ⚠️

Script to add keywords to file name?

Comments

5 comments

  • Eric Valk
    [quote="AdamTracksler" wrote:
    I have a catalog of products, and I would like to be able to export the keywords (the individual product name) when I export the images. I could do this on Lightroom, but cannot seem to do this in C1. I hoped maybe there was a script I could run....

    In the export menu you can add Metdata information, but not keywords, to the image name.

    If each of your images has only 1 keyword to describe the product, what I would do is run an Applescript to copy the keyword of each image to a Metadata field you don't normally use (e.g. "Getty original filename") ... or perhaps a Metadata field which is approriate for this use (e.g. "content headine")

    Having done that, you can use the standard features of the export menu to add the Metadata field to the name of the exported image.

    I have tested this script

    ##{ some code to determine the name of your document as COPDocName }
    set COPDocName to 1 -- quick and dirty approach
    tell application "Capture One 11" to tell document COPDocName to tell collection "All Images" to set count_All_Variants to count of every variant

    repeat with variantCounter from 1 to count_All_Variants
    tell application "Capture One 11" to tell document COPDocName to tell collection "All Images" to tell variant variantCounter
    set keywordcount to count of keywords
    set variantName to name
    if 0 < keywordcount then
    -- this assumes that there is only 1 keyword
    -- if there are more keywords, you will need to add some code to find the correct keyword (perhaps based on the parent)
    set {KWname, KWparent} to {name, parent} of keyword 1
    set KWparent to KWparent as text
    if KWparent ≠ "missing value" then set KWname to KWparent & " " & KWname -- optionally drop this line
    set content headline to KWname
    log {variantName, keywordcount, "Done"}
    else
    log {variantName, keywordcount, "Not Done"}
    end if
    end tell
    end repeat



    0
  • AdamTracksler
    Do I need to modify anything in this script to put the keywords in the Getty original file name? Or is it good to go?
    0
  • Eric Valk
    [quote="AdamTracksler" wrote:
    Do I need to modify anything in this script to put the keywords in the Getty original file name? Or is it good to go?

    The script as written will put the keyword info into the "Content Headline" field.

    To put the keyword info into the Getty original filename field, you need to replace the line "set content headline to KWname" by "set Getty original filename to KWname"

    The script is written assuming that you only have one keyword for each image. If some or all images have more than 1 keyword, then we have to add something to check each keyword name (or parent) and choose the correct one. But not knowing if you have more than 1 keyword per image, and not knowing how to recognise the appropriate keyword if there is more than 1, I haven't supplied that.

    Note that the script as written will only run reliably if you have only one catalog or session open. One could make it reliable even if multiple documents were open, but that would add complexity, and for a beginner in Applescript, that is not a good choice.
    0
  • AdamTracksler
    Most only have one keyword, but there are many that have multiples.

    What should I do in that case?
    0
  • Eric Valk
    [quote="AdamTracksler" wrote:
    Most only have one keyword, but there are many that have multiples.
    What should I do in that case?

    Do you want to include all keywords if there are multiples?

    If not, we need a way to identify which are the keywords to be used, and which are not
    There are two choices
    1) Define a rule to recognise the valid key words for this purpose
    2) Define a rule to recognise the invalid key words for this purpose

    More than 1 rule is also possible.

    Then we can make a simple loop to check all keyords of a variant and either reject the invalid ones or accept the valid ones.

    One way of recognition is a character sequence e.g. contains the sequence "rem", starts with "_", starts with a capital letter

    Another way of recognition is if you have hierarchical keywords. The keywords are recognised according to their parents are accepted or not accpted.

    Another way is to make a list of keywords to be rejected. This is practical if the list is short and does not change much.

    If someone was absolutely new to your system, and limited intelligence, how would you explain twhich are the keywords to be used or not used?

    If you can state a few simple rules, I can write some simple Applescript to impleement them.
    0

Post is closed for comments.