Apple script syntax error

Discussion in 'Mac Programming' started by s.m.t., Nov 29, 2018.

  1. s.m.t. macrumors regular

    s.m.t.

    Joined:
    Mar 7, 2010
    #1
    Where is my error? Trying to use an Apple script to call EXIFtool to set some meta data using the script function in Capture One...
    Code:
    set Aperture to 1.8
    
    set theRespondedAperture to the text returned of ¬
        (display dialog ¬
            "What's the aperture value?" default answer Aperture ¬
            with icon note buttons {"Cancel", "Continue"} default button "Continue")
    
    tell application "Capture One 12"
        set selectedVariants to get selected variants
        repeat with i from 1 to number of items in selectedVariants
            set this_item to item i of selectedVariants
            set theID to id of (parent image of this_item)
            do shell script "/usr/local/bin/exiftool -overwrite_original_in_place -preserve -m" & ¬
                " -LensSerialNumber='1240777'" & ¬
                " -Lens='Nikon Series E 50mm 1:1.8 LTii'" & ¬
                " -LensModel='Nikon Series E 50mm 1:1.8 LTii'" & ¬
                " -LensType='Nikon Series E 50mm 1:1.8 LTii'" & ¬
                " -FocalLength='50'" & ¬
                " -FocalLengthIn35mmFormat='54'" & ¬
                " -MaxApertureValue='1.8'" & ¬
                " -FNumber=" & theRespondedAperture & ¬
                " " & quoted form of theID
            --Remove the log statement when no longer needed. Used just for demo
            -- log theID
            reload metadata this_item
        end repeat
    end tell
    I get this error:
    Code:
    error "Capture One 12 got an error: Error: File not found - 7773" number 1
     
  2. chown33 Moderator

    Staff Member

    Joined:
    Aug 9, 2009
    Location:
    bedlam
    #2
    I don't think you have an AppleScript syntax error. I think you're passing a number (7773) to the exiftool command, instead of the pathname of the file to operate on. As a result, exiftool is existing with an error message on stderr ("File not found - 7773) and an exit status of 1, which is the standard way of signalling a command's failure.

    I suggest uncommenting the "log theID" line, and also placing it before the do shell script, instead of after it. Post the output, within CODE tags, if it's not the number 7773.

    I know nothing about "Capture One 12", but I find it a little odd that a property would be named "id" yet hold the pathname of a file. Based on nothing but experience and gut instinct, I'd be looking for a different property, perhaps something with the word "name" or "file" in it, or perhaps "alias", as that's the AppleScript term. If you don't see anything, please post the scripting dictionary.

    The exiftool is going to need the Posix path property from the alias.
     
  3. s.m.t. thread starter macrumors regular

    s.m.t.

    Joined:
    Mar 7, 2010
    #3
    Thanks, I will make that change and report the output...

    I pulled that part from another CaptureOne script example I found, but it also is reported in the script dictionary for Capture One:
    variant n : An Image Variant.

    elements

    contains keywords, layers, readouts, output events; contained by application, documents, collections, images.

    properties

    name (text, r/o) : The name of the parent image

    id (text, r/o) : The unique identifier of the variant

    parent image (image, r/o) : The parent image of the variant

    pick (boolean) : Is this the picked variant

    selected (boolean, r/o) : Is this variant selected in the collection containing it.

    engine (integer, r/o) : The processing engine version in use for this variant. Generally corresponds to the version of Capture One under which the image was originally edited, multiplied by 100.

    adjustments (adjustment settings) : The variant's background layer adjustment settings.

    styles (list of text) : The name(s) of styles and/or presets that have been applied to this variant's background layer.

    exposure meter (real, r/o) : Center-weighted measure of exposure in the original capture, denoted on a ±2 EV scale.

    color tag (integer)

    rating (integer)

    contact creator (text)

    contact creator job title (text)

    contact address (text)

    contact city (text)

    contact state (text)

    contact postal code (text)

    contact country (text)

    contact phone (text)

    contact email (text)

    contact website (text)

    content headline (text)

    content description (text)

    content category (text)

    content supplemental categories (text)

    content subject codes (text)

    content description writer (text)

    image intellectual genre (text)

    image scenes (text)

    image location (text)

    image city (text)

    image state (text)

    image country (text)

    image country code (text)

    status title (text)

    status job identifier (text)

    status instructions (text)

    status provider (text)

    status source (text)

    status copyright notice (text)

    status rights usage terms (text)

    Getty personalities (text)

    Getty original filename (text)

    Getty parent MEID (text)

    latitude (real, r/o)

    longitude (real, r/o)

    altitude (real, r/o)

    applied LCC name (text, r/o) : The name of the image used to create the lens cast correction applied to this variant.

    LCC color cast (boolean) : Does the variant use lens cast correction to improve color cast.

    LCC dust removal (boolean) : Does the variant use lens cast correction to remove dust.

    LCC uniform light (boolean) : Does the variant use lens cast correction to improve light uniformity.

    LCC uniform light amount (integer) : The percentage of light uniformity improvement from lens cast correction.

    crop (rectangle) : The variant's crop rectangle {centerX, centerY, width, height}

    crop size (point) : The size of the crop in pixels {width, height}

    crop width (integer) : The width (in pixels) of the variant's crop

    crop height (integer) : The height (in pixels) of the variant's crop

    crop center (point) : The center of the crop in pixels {x, y} Bottom Left is the origin

    crop centerX (integer) : The horizontal center (in pixels) of the variant's crop (relative to Left edge)

    crop centerY (integer) : The vertical center (in pixels) of the variant's crop (relative to bottom edge)

    responds to

    process, autocrop, clone variant, reload metadata, sync metadata, copy adjustments, apply adjustments, reset adjustments, pick normalize, apply normalize, upgrade engine, autoadjust, promote, demote, create LCC, apply LCC, maximum crop.
     
  4. chown33 Moderator

    Staff Member

    Joined:
    Aug 9, 2009
    Location:
    bedlam
    #4
    I don't see anything in the dictionary that looks like a filename, pathname, alias, or anything similar.

    In fact, it looks like a 'variant' is a collection of setting, attributes, or operators waiting to be applied to an image. I'm also judging by the verbs that can be applied to a variant: process, autocrop, etc.

    I suspect you'll have to get the image object that's being operated on, and see if it has a file or alias you can get. Or maybe the document that holds the 'variant'. Or some other container object that holds the variant.

    At this point I'm just guessing. If there's a reference doc that discusses the app and its scripting dictionary, please post the URL, so I can get a better understanding of what the app does and how that's represented in the scripting dictionary.
     
  5. s.m.t. thread starter macrumors regular

    s.m.t.

    Joined:
    Mar 7, 2010
    #5
    Thanks! I also posted this over in the official Capture One forums and got it working with some help from a user there... Turns out those references are for an older version of C1...

    Here the post if anyone is interested...
    https://forum.phaseone.com/En/viewtopic.php?f=75&t=29412
     

Share This Page

4 November 29, 2018