EXIFtool script

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

EXIFtool script

Postby NNN636504158446775775 » Fri Nov 30, 2018 1:15 am

Can someone point out where I am going wrong... Script keeps returning: error "Capture One 12 got an error: Error: File not found - 7773" number 1

Code: Select all
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'" & ¬
         " " & 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
NNN636504158446775775
 
Posts: 5
Joined: Mon Jan 01, 2018 4:03 pm

Re: EXIFtool script

Postby Eric Nepean » Fri Nov 30, 2018 1:55 am

Hi
One key issue is that you are asking Capture One to run a "do shell script" - but "do shell script" is not a command that you can send to Capture One - if you look in the Capture One Dictionary you will not find it.

"do shell script" is a command of Scripting Additions: Standard Additions: Miscellaneous Commands (see AppleScript Help, also the Applescript Dictionary for Standard Additions)

So you have to write: tell me to do shell script ..... which asks the entity which is running the the script to execute it, and this entity (Script Editor for now) will end up finding something in OSX to do it.

A second key issue is that the ID of an image is no longer its path in Capture One 12. The ID was the path, in previous versions of Capture One, but that was a poor implementation.This is better, now its just a number.

To get the file path, you need to use: get path of (parent image of this_item)

Below is a slight modification of your code, with the shell script part temporarily bypassed.

Open the Script Editor Log, and click on the replies window. When you run this script, you will see the values returned by Capture One in the replies window.

Once you are comfortable that this part is working, then you can remove the the "if false" (permanent) or replace it by "If true" (temporary).

I note that your ExifTool command doesn't write the value of theRespondedAperture to the file, you will probably want to fix that too.

Code: Select all
use AppleScript version "2.4"
use scripting additions

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")

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)
      set theFilePath to path of (parent image of this_item)
      if false then
         tell me to ¬
            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'" & ¬
               " " & quoted form of theFilePath
         --Remove the log statement when no longer needed. Used just for demo
         -- log theID
         reload metadata this_item
      end if
   end repeat
end tell
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 445
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: EXIFtool script

Postby NNN636504158446775775 » Fri Nov 30, 2018 3:08 am

Thanks that is super helpful! That makes sense as I got some of this from an old script I found on the net, it reference capture one 10...

I have not done anything with AppleScript, so I am learning the syntax as I go...

Guessing this is what your referring to... I see how it is finding the file. I set the respondedaperture variable but it's not updating that, so I must have something wrong there still...
Code: Select all
tell application "Script Editor"
   display dialog "What's the aperture value?" default answer 1.8 with icon note buttons {"Cancel", "Continue"} default button "Continue"
      --> {button returned:"Continue", text returned:"1.8"}
end tell
tell application "Capture One 12"
   get selected variants
      --> {variant id "7780" of collection id "2" of document "Capture One Catalog"}
   get id of parent image of variant id "7780" of collection id "2" of document "Capture One Catalog"
      --> "7773"
   get path of parent image of variant id "7780" of collection id "2" of document "Capture One Catalog"
      --> "/Volumes/Data/Photography/2018/11/16/_DSF7797.RAF"
end tell
tell current application
   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='theRespondedAperture' '/Volumes/Data/Photography/2018/11/16/_DSF7797.RAF'"
      --> "    1 image files updated"
end tell
tell application "Capture One 12"
   reload metadata variant id "7780" of collection id "2" of document "Capture One Catalog"
end tell

NNN636504158446775775
 
Posts: 5
Joined: Mon Jan 01, 2018 4:03 pm

Re: EXIFtool script

Postby Eric Nepean » Fri Nov 30, 2018 5:53 am

Yes, that's it exactly.

I think what may be happening is that the script is trying to write the name of the variable instead of the value of the variable to the Aperture Value of the file. This is guaranteed to cause problems :D

We should be seeing -MaxApertureValue='1.8' in the reply
instead of -MaxApertureValue='theRespondedAperture'

Possibly what has happened is that you have a line like this " -MaxApertureValue='theRespondedAperture'" & ¬
where what you need is a line like this: " -MaxApertureValue='" & theRespondedAperture & "'" & ¬

Here you are joing three strings together with the & operator
string 1: -MaxApertureValue='
string 2: the contents of the variable theRespondedAperture converted to a string
string 3: '

As on every line in this shel script, the last & operator joins all this to the string on the next line, with ¬ as your line continuation character.
Cheers, Eric
[late 2015 iMac, 4GHz i7, 24GB RAM, external SSDs. GX8, E-M1, GX7, GM5, GM1 ....]
Eric Nepean
 
Posts: 445
Joined: Sat Oct 25, 2014 8:02 am
Location: Ottawa

Re: EXIFtool script

Postby NNN636504158446775775 » Fri Nov 30, 2018 11:48 pm

Thanks!! That is exactly what was needed and completely makes sense...

Thanks for the help! Now I am going to try and build a script that will read the EXIF tags in the Fuji RAW files and set the Film Simulation to match...

Code: Select all
tell application "Script Editor"
   display dialog "What's the aperture value?" default answer 1.8 with icon note buttons {"Cancel", "Continue"} default button "Continue"
      --> {button returned:"Continue", text returned:"1.8"}
end tell
tell application "Capture One 12"
   get selected variants
      --> {variant id "7780" of collection id "2" of document "Capture One Catalog"}
   get id of parent image of variant id "7780" of collection id "2" of document "Capture One Catalog"
      --> "7773"
   get path of parent image of variant id "7780" of collection id "2" of document "Capture One Catalog"
      --> "/Volumes/Data/Photography/2018/11/16/_DSF7797.RAF"
end tell
tell current application
   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' -ApertureValue='1.8' '/Volumes/Data/Photography/2018/11/16/_DSF7797.RAF'"
      --> "    1 image files updated"
end tell
tell application "Capture One 12"
   reload metadata variant id "7780" of collection id "2" of document "Capture One Catalog"
end tell
NNN636504158446775775
 
Posts: 5
Joined: Mon Jan 01, 2018 4:03 pm

Re: EXIFtool script

Postby Emile » Sat Dec 01, 2018 12:33 am

NNN636504158446775775 wrote:Now I am going to try and build a script that will read the EXIF tags in the Fuji RAW files and set the Film Simulation to match...


There’s no need! At least, C1 automatically sets the right film sim for my x100f, x-t2 and x-t3 as long as the curve is set to “auto”.
Fujifilm, Mac, Capture One user since v3.0
Emile
 
Posts: 146
Joined: Fri Jan 11, 2008 2:01 pm
Location: New York

Re: EXIFtool script

Postby NNN636504158446775775 » Sat Dec 01, 2018 12:50 am

Emile wrote:
NNN636504158446775775 wrote:Now I am going to try and build a script that will read the EXIF tags in the Fuji RAW files and set the Film Simulation to match...


There’s no need! At least, C1 automatically sets the right film sim for my x100f, x-t2 and x-t3 as long as the curve is set to “auto”.

Hmm... Mine is not doing that... I took a shot with Arcos and the import dialog preview was right but once the import was complete it changed... I haven't imported anything into version 12 yet... Let me try...
NNN636504158446775775
 
Posts: 5
Joined: Mon Jan 01, 2018 4:03 pm

Re: EXIFtool script

Postby NNN636504158446775775 » Sat Dec 01, 2018 1:46 am

Woah, it works! It doesn't change to the correct film sim in the drop down menu, but it does match the image... That's definitely new to version 12...
NNN636504158446775775
 
Posts: 5
Joined: Mon Jan 01, 2018 4:03 pm

Re: EXIFtool script

Postby Emile » Sat Dec 01, 2018 1:50 am

NNN636504158446775775 wrote:Woah, it works! It doesn't change to the correct film sim in the drop down menu, but it does match the image... That's definitely new to version 12...


Yep, that’s v12. Turned me into one happy camper!

Have a great weekend!
Fujifilm, Mac, Capture One user since v3.0
Emile
 
Posts: 146
Joined: Fri Jan 11, 2008 2:01 pm
Location: New York


Return to Scripting



Who is online

Users browsing this forum: No registered users and 1 guest