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. ⚠️

Exiftool script: can someone help me please?

Comments

5 comments

  • Eric Valk
    The obvious error is that you are telling Capture One to run a shell script. You should be telling the current application, like the code below. That gets rid of the error, and works for my Olympus images, except that the new value of Aperture is not copied back into Capture One.

    It may be the Capture One doesn't resynch this data, or it may be that it uses a different Metadata field.


    tell current application to do shell script ¬
    "/usr/local/bin/exiftool -overwrite_original_in_place -preserve -m " & ¬
    " -Make=" & theRespondedMake & ¬
    " -Model=" & theRespondedModel & ¬
    " -Lens=" & theRespondedLens & ¬
    " -EXIF:ApertureValue=" & theRespondedAperture & ¬
    " -FocalLength=" & theRespondedFocalLength & ¬
    " " & quoted form of theID
    0
  • Eric Valk
    Here is my slightly modified version of the script with some notes about behaviour.

    An important note is that removing a Metadata Tag from the file and then reloading the Metadata into Capture One does NOT result in Capture One removing that Metedata Tag from its data base. There is no way to cause Capture One to remove a Metadata Tag you no longer want.

    Particularly tricky is the Focal Length Tag. For images taken with completely manual lenses, the Focal Length Tag is initially not present. If you add the Focal Length Tag with a value of say 55mm, no problem, Capture One will add it to it's database for that image.

    But if you later decide that you didn't really know the focal length after all (as I did), removing the Focal Length Tag using ExifTool will result in Capture One retaining the 55mm value. If you set the Focal Length Tag to 0, Capture One will ignore it. The best I could manage is set the Focal Length Tag to 1mm.



    use AppleScript version "2.4" -- Yosemite (10.10) or later
    use scripting additions

    set DefMake to "Pentax"

    set theRespondedMake to the text returned of ¬
    (display dialog ¬
    "What's the camera make?" default answer DefMake ¬
    with icon note buttons {"Cancel", "Continue"} default button "Continue")
    ## in case there are multiple words in the Make. But entering nothing will remove this Exif Tag
    if 0 < length of theRespondedMake then set theRespondedMake to quoted form of theRespondedMake

    set DefModel to "MX"

    set theRespondedModel to the text returned of ¬
    (display dialog ¬
    "What's the camera model?" default answer DefModel ¬
    with icon note buttons {"Cancel", "Continue"} default button "Continue")
    ## in case there are multiple words in the Model. But entering nothing will remove this Exif Tag
    if 0 < length of theRespondedModel then set theRespondedModel to quoted form of theRespondedModel

    set DefLens to "SMC"

    set theRespondedLens to the text returned of ¬
    (display dialog ¬
    "What's the lens used?" default answer DefLens ¬
    with icon note buttons {"Cancel", "Continue"} default button "Continue")
    ## in case there are multiple words in the Lens. But entering nothing will remove this Exif Tag
    if 0 < length of theRespondedLens then set theRespondedLens to quoted form of theRespondedLens

    set DefAperture to 1.8

    set theRespondedAperture to the text returned of ¬
    (display dialog ¬
    "What's the aperture value?" default answer DefAperture ¬
    with icon note buttons {"Cancel", "Continue"} default button "Continue")
    ## Entering nothing will remove this Exif Tag from the file
    set DefFocalLength to 50

    set theRespondedFocalLength to the text returned of ¬
    (display dialog ¬
    "What's the focal length?" default answer DefFocalLength ¬
    with icon note buttons {"Cancel", "Continue"} default button "Continue")
    ## Entering nothing will remove this Exif Tag from the file
    ## Entering "0" will result in Capture One ignoring it

    tell application "Capture One 11"
    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)

    ## So that I can log it if necessary
    set theExifToolCommand to ¬
    "/usr/local/bin/exiftool -overwrite_original_in_place -preserve -m " & ¬
    " -Make=" & theRespondedMake & ¬
    " -Model=" & theRespondedModel & ¬
    " -Lens=" & theRespondedLens & ¬
    " -EXIF:ApertureValue=" & theRespondedAperture & ¬
    " -FocalLength=" & theRespondedFocalLength & ¬
    " " & quoted form of theID

    tell current application to do shell script theExifToolCommand

    ## Metadata tags which are removed from the image file will result in Capture One retaining the previous value.
    ## There is no way to cause Capture One to remove a Metadata tag, once it has loaded it.
    reload metadata this_item
    end repeat
    end tell


    0
  • Marc Desimpelaere
    Thanks Eric, greatly appreciated.

    Do I understand correctly that the code
    if 0 < length of theRespondedMake then set theRespondedMake to quoted form of theRespondedMake

    is used to leave the field as it is if nothing is entered?
    0
  • Eric Valk
    [quote="Marc Desimpelaere" wrote:
    Thanks Eric, greatly appreciated.

    Do I understand correctly that the code
    if 0 < length of theRespondedMake then set theRespondedMake to quoted form of theRespondedMake

    is used to leave the field as it is if nothing is entered?

    Without this, it works fine if I enter "Panasonic" or nothing. But if I enter "Olympus Imaging Corp.", which is the usual value for an Olympus camera, the Exiftool command willl fail as each word is taken as a separate argument, and ExifTool tries to treat "Imaging" as a file name.

    To get around this problem, I put the results into quoted form, which causes the command string to contain 'Panasonic' or
    'Olympus Imaging Corp.' (quotes included).

    But now entering nothing results in '' (two single quotes). I suppose that doesn't really matter for this field, but to maintain the original behaviour of deleting the tag I added the condition if " 0< length of ... ".

    For a Tag like "Maker", perhaps a better response might be to reject no input or a blank input; this can be done right in the "display dialog" command by adding those optionss.
    0
  • Marc Desimpelaere
    Got it, super!

    Many thanks again!
    0

Post is closed for comments.