Applescript to run shell script to change EXIF data in image

Discussion regarding all scripting related questions
Please DO NOT post to this thread anything that is not directly related to scripting of Capture One.

Applescript to run shell script to change EXIF data in image

Postby rollbahn » Thu May 11, 2017 6:44 am

I am testing out Capture One to switch over from Lightroom and as I shoot film and scan at home I always like to add in the camera and lens data. LR has plenty of plugins for this task but in Capture One it looks like my only option to change Camera Make/Model and Lens etc in the EXIF is to run exiftools via an Applescript.

I have tried a few things and had a good look around online but can't see how to achieve what I want:

1. Highlight one or more images in Grid view
2. Go to the menu and choose the script and have it loop through and update the EXIF data on the selected images.

The code below is what I have tried so far from bits and pieces I have found but I get an error "No File Specified".

Any help would be great - thanks.

Code: Select all
tell application "Capture One 10"
   set selectedVariants to (get selected variants)
   tell document 1 -- as far as I can tell there is only  ever 1 document     
      if selectedVariants is {} then
         display notification "No images selected -  select one or more images"
      else
         repeat with counter from 1 to count of selectedVariants
            do shell script "/usr/local/bin/exiftool -lens='Leica Summicron-M 35mm f/2 Type IV 7 Element'"
         end repeat
      end if
   end tell
end tell
rollbahn
 
Posts: 3
Joined: Sat Mar 24, 2012 6:37 am

Re: Applescript to run shell script to change EXIF data in i

Postby SeanMurp » Thu May 11, 2017 8:12 pm

Hi rollbahn,
I think it is an issue with your shell script line. Exiftool requires the path of the image file that it will be modifying and that is missing from your code. So, in theory, that would need to be added to the end of that line.

Drag-and-drop outside of Capture One is pretty easy but I've not been able to figure out how to do it within Capture One.

One question, have you been able to successfully change the lens field of the EXIF data? Capture One doesn't seem to allow it within the app and when I try running the code independently exiftool doesn't appear to change that field. This is the code I used:

Code: Select all
exiftool -lens='Leica Summicron-M 35mm f/2 Type IV 7 Element' /Users/seanmurp/Desktop/Output/ghjkl1234567890/ghjkl1234567890_01.JPG


Exiftool says it updated the file but when I check the file is still showing the original lens data.
SeanMurp
 
Posts: 71
Joined: Wed Nov 02, 2016 4:30 am

Re: Applescript to run shell script to change EXIF data in i

Postby SeanMurp » Thu May 11, 2017 9:36 pm

And if you don't mind having the data in a different field than there is Capture One specific code to do this. This is what we use to add a bunch of metadata into the fields that Capture One's dictionary can natively interact with.

Code: Select all
tell application "Capture One 10"
   
   set selectedVariants to (get selected variants)
   
   tell document 1 -- as far as I can tell there is only  ever 1 document     
      if selectedVariants is {} then
         display notification "No images selected -  select one or more images"
      else
         repeat with |counter| from 1 to count of selectedVariants
            set thisVariant to item |counter| of selectedVariants
            set oldStource to get status source of thisVariant
            set contact city of thisVariant to "YourCityName"
            set contact country of thisVariant to "YourCountryName"
            set contact address of thisVariant to "YourAddress"
            set content headline of thisVariant to "YourHeadline"
            set contact creator of thisVariant to "PhotographerName"
            set contact creator job title of thisVariant to "YourJobTitle"
            set contact postal code of thisVariant to "YourPostalCode"
         end repeat
      end if
   end tell
end tell


And you can find the full list of fields that Capture One can write to by looking at the dictionary within Script Editor and look under Variant.
SeanMurp
 
Posts: 71
Joined: Wed Nov 02, 2016 4:30 am

Re: Applescript to run shell script to change EXIF data in i

Postby rollbahn » Thu May 11, 2017 11:30 pm

Thanks - yes exiftool requires the file path but the script should be able to grab that from selecting it in the grid view which is what I am trying to achieve. I have done the same thing in Lightroom heaps of times and the plugins just grab the file path for the current highlighted images. Makes it easy to quickly fix a bunch of images visually rather than via the CLI.

I think what you have should work - how are you checking it has worked? Remember that in Capture One you will need to re-read the metadata to see the change. Best to run exiftool on the image in the CLI to see the change immediately.

With regards to other Capture One fields - I definitely want it in the EXIF as that works well across lots of situations.

Hopefully someone can help - I am guessing it is a dead simple solution if you're familiar with AppleScript/Capture One.
rollbahn
 
Posts: 3
Joined: Sat Mar 24, 2012 6:37 am

Re: Applescript to run shell script to change EXIF data in i

Postby SeanMurp » Fri May 12, 2017 4:26 pm

Right, but your AppleScript code will need to find the path of the image file selected and enter that into the end of the exiftool shell script command.

So, in the "repeat with counter from 1" section" you'll need to retrieve the path of the selected file, set the result as a variable and then add that variable to the end of the exiftool shell script. Something like this (this has not been tested but just for display purposes):

Code: Select all
...
      else
            repeat with counter from 1 to count of selectedVariants
        set thePath to quoted form of POSIX path of thisVariant
                  do shell script "/usr/local/bin/exiftool -lens='Leica Summicron-M 35mm f/2 Type IV 7 Element' " & thePath
            end repeat
     ...
SeanMurp
 
Posts: 71
Joined: Wed Nov 02, 2016 4:30 am

Re: Applescript to run shell script to change EXIF data in i

Postby rollbahn » Sun May 14, 2017 3:18 am

Great thanks for your help - that was very stupid of me to miss that! I'll have a play around with that script and see what I can figure out
rollbahn
 
Posts: 3
Joined: Sat Mar 24, 2012 6:37 am


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest