Benches macOS

4

Spotlight Comment to IPTC Field

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hi there,

maybe someone can help me.

i should say that i have absolutely no idea about apple script.

I want to create an automator plugin that takes the spotlight comments of a chosen photo and copies these to an iptc field.

I think the script here:
http://discussions.apple.com/message.jspa?messageID=7203132#7203132 would be the right starting point but then there must be some command that uses GraphicConverter or something similar to write to iptc.

Looking forward to your answers, thx in advance

ben

4 replies

Sign in or join Beachball Help to reply.

  1. 0

    Hiroto

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hello

    You may try something like the following script.

    In the current form, it will ask you to choose a file and then copy its comment to IPTC caption field. For use with Automator, replace the run handler with the one for Automator action that is now commented out.

    Tested with GraphicConverter Classic v5.9.5 under OS9.1.

    (GC v5.9.5 cannot put Unicode text (UTF-16) into IPTC field. GC v6.0.2 or later provides complete Unicode support in IPTC metadata according to the version history at the developer's site. You'd need the recent version because AppleScript 2.0 under OSX10.5 uses only Unicode text for internal text object.)

    Hope this may help,

    H

    --SCRIPT

    on run

    open {choose file}

    end run

    (* -- for Automator action

    on run {input, parameters}

    open (input as list)

    return input

    end run

    *)

    on open aa

    repeat with a in aa

    set a to a as alias

    tell application "Finder" to set c to a's comment

    if c is not "" then

    tell application "GraphicConverter" -- *

    set file iptc a to {c}

    end tell

    end if

    end repeat

    end open

    (*

    * GC v6.0.2 or later should be required for complete Unicode support in IPTC metadata.

    cf.
    http://www.lemkesoft.com/content/162/new-functions-and-versions.html

    *)

    --END OF SCRIPT

  2. 0

    dev_sleidy

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    'I want to create an automator plugin that takes the spotlight comments of a chosen photo and copies these to an iptc field. ' - which 'IPTC' field?

    As per 'GraphicConverter's AppleScripts' Library's 'GraphicConverter.asdictionary' file - there are:

    IPTC caption, IPTC captionwriter, IPTC headline, IPTC specialinstructions, IPTC byline, IPTC bylinetitlee, IPTC credit, IPTC source, IPTC objectname, IPTC datecreated, IPTC city, IPTC state, IPTC country, IPTC reference, IPTC category, IPTC copyright, IPTC urgency, IPTC subcategory, and IPTC keywords

    Sample AppleScript code:

    -- Code starts here --

    on run

    open (choose file with multiple selections allowed)

    end run

    on open (dItems)

    repeat with i in dItems

    tell application "Finder" to set fComment to comment of i

    try

    tell application "GraphicConverter"

    open i

    tell window 1

    set IPTC caption to fComment

    close saving yes

    end tell

    end tell

    end

    end repeat

    end open

    -- Code ends here --

    Save the above code as an application (AppleScript applet). The applet can be double clicked on, or files to be processed - dragged onto it.

    ---

    Or replace the contents of 'Automator's 'Automator' Library's 'Run AppleScript' Action with ...

    -- Code starts here --

    on run {input, parameters}

    tell application "GraphicConverter" to activate

    delay 1.0

    repeat with i in input

    tell application "Finder" to set fComment to comment of i

    try

    tell application "GraphicConverter"

    open i

    tell window 1

    set IPTC caption to fComment

    close saving yes

    end tell

    end tell

    end

    end repeat

    return input

    end run

    -- Code ends here --

    Save the above code as an 'Automator' 'Finder' Plug-in.

    ---

    If any other IPTC parameter is to contain the file's comment entry, then replace 'IPTC caption' in ...

    set IPTC caption to fComment

    ... with the desired IPTC parameter.

    The code segments provided above - offers minimal error capturing. One is to assume that only files capable of being opened and (an IPTC parameter) modified by 'GraphicConverter' - are dragged onto the applet, or selected via the 'Automator' 'Finder' Plug-in's contextual menu.

  3. 0

    benben29

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks a lot!!

    Works perfectly.

  4. 0

    jasonh1234

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    What about in reverse?

    I have JPGs with IPTC info already (added from iPhoto 08's keywords on export.)

    but I want to convert these JPGs to PDF and keep that IPTC info as a spotlight comment for the PDF