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

get file info script

Comments

5 comments

  • Zdeněk Macháček

    Nice one. Do you know how to obtain data about lens (name of the lens) - within C1? I mean without external tools like Exiftool.

    0
  • Hugues

    Thanks for the kind words.

    You can't really get the lens through C1

    Or more precisely, you can if C1 supports the lens profile *and* it has been applied as a lens correction. 

    Then you would use  this version that uses the lens correction

    use AppleScript version "2.4" -- Yosemite (10.10) or later
    use scripting additions
    use script "Dialog Toolkit Plus" version "1.1.3"
    -- Récupère les infos souhaitée et les présente dans une boite de dialogue
    -- Fonctionne sur une selection plusieurs photos  
     
     
    tell application "Capture One 21"
    set theSelectedVariantList to get selected variants
    if 0 = (count of theSelectedVariantList) then
    tell current document to tell current collection to set theVariantList to every variant
    else
    set theVariantList to theSelectedVariantList
    end if
    end tell
    set theVariantCount to get count of theVariantList
    if theVariantCount = 0 then error "Did not find any variants in \"" & currentDocName & "\""
     
    repeat with theVariant in theVariantList
    tell application "Capture One 21"
    set ¬
    {{theDimL, theDimP}, theAltitude, theAperture, theCameraMake, theCameraModel, theCameraOwner, ¬
    theCaptureDate, theExposureCompensation, theExposureProgram, theFlashMode, theFocalLength, ¬
    theISO, theLatitude, theLongitude, theMeteringMode, theSpeed, theWB, theExtension, ¬
    theSize, theId, theName, thePath} ¬
    to get ¬
    {dimensions, EXIF altitude, EXIF aperture, EXIF camera make, EXIF camera model, EXIF camera owner, ¬
    EXIF capture date, EXIF exposure compensation, EXIF exposure program, EXIF flash mode, EXIF focal length, ¬
    EXIF ISO, EXIF latitude, EXIF longitude, EXIF metering mode, EXIF shutter speed, EXIF white balance, extension, ¬
    file size, id, name, path} ¬
    of parent image of theVariant
    set {theRating, theLocation, theCity, theState, theCountry, theColorTag} ¬
    to get ¬
    {rating, image location, image city, image state, image country, color tag} ¬
    of theVariant
    set {name_s, parent_s} to get {name, parent} of keywords of theVariant
    set theLens to get lens profile of lens correction of theVariant
     
    end tell
     
    set byteSize to theSize as integer
    set MBSize to (round (byteSize / 1.0E+5)) / 10 -- transforme en Mégaoctets
    if theCameraOwner is equal to missing value then set theCameraOwner to ""
    set theProject to my getProject(thePath)
     
    set theKeywordPhrase to makeKeywordPhrase({name_s, parent_s})
    set theRatingStars to makeRating(theRating)
    set theColor to makeColorTag(theColorTag)
     
    set theBoldMessage to ¬
    theISO & space & space & space & space & theFocalLength & space & space & space & space & ¬
    theSpeed & space & space & space & space & theAperture
     
    set theMessage to ¬
    "Correction d'expo." & space & ":" & space & theExposureCompensation & space & "ev" & return & ¬
    "Programme" & space & ":" & space & theExposureProgram & return & ¬
    "Mode de mesure" & space & ":" & space & theMeteringMode & return & ¬
    "Flash" & space & ":" & space & theFlashMode & return & ¬
    "Balance des blancs" & space & ":" & space & theWB & return & ¬
    theLens & return & return & ¬
    theCaptureDate & return & ¬
    theLocation & return & ¬
    theCity & return & ¬
    theState & return & ¬
    theCountry & return & ¬
    "Latitude" & space & ":" & space & theLatitude & space & space & space & "Longitude" & space & ":" & space & theLongitude & return & ¬
    "Collection" & space & ":" & space & theProject & return & return & ¬
    "Fichier" & space & ":" & space & theName & return & ¬
    "Taille" & space & ":" & space & MBSize & space & "Mo" & return & ¬
    "Dimensions" & space & ":" & space & theDimL & space & "x" & space & theDimP & return & ¬
    "Propriétaire" & space & ":" & space & theCameraOwner & return & return & ¬
    theKeywordPhrase & return & ¬
    theColor & space & theRatingStars
     
    -- Placeholdders for different options in the displayed parameters 
    --  thePath & return & ¬
    --  "Format" & space & ":" & space & theExtension & return & ¬
    --  "Fichier" & space & ":" & space & theName & return & ¬
    -- "Altitude" & space & ":" & space & theAltitude & return & ¬
    -- "Marque" & space & ":" & space & theCameraMake & return & ¬
    --  "ID" & space & ":" & space & theId & return 
     
    --display dialog theMessage with title theName buttons {"OK"} default button 1 giving up after 15
    set accViewWidth to 300
    set {theButtons} to create buttons {"OK"} default button 1 given «class btns»:2
    set {instructionsLabel, theTop, theWidth} to create label theMessage bottom 0 max width accViewWidth aligns left aligned with multiline
    set {theRule, theTop} to create rule (theTop + 18) rule width accViewWidth
    set {boldLabel, theTop} to create label theBoldMessage bottom theTop + 12 max width accViewWidth control size large size aligns center aligned with bold type
    set allControls to {instructionsLabel, theRule, boldLabel}
     
    if theCameraModel is missing value then set theCameraModel to "Info"
     
    set {buttonName, controlsResults} to ¬
    display enhanced window ¬
    theCameraModel acc view width accViewWidth ¬
    acc view height theTop ¬
    acc view controls allControls ¬
    buttons theButtons ¬
    giving up after 15 ¬
    with align cancel button
     
     
    end repeat
     
    on makeKeywordPhrase({name_s, parent_s})
    set theKeywordPhrase to ""
    set theStructuredList to {}
     
    repeat with i from 1 to count of name_s
    set {parentKeyword, aKeyword} to {get item i of parent_s, get item i of name_s}
    try
    if parentKeyword is not equal to missing value then
    if theStructuredList is equal to {} then
    set theStructuredList to {{parentKeyword, {aKeyword}}}
    else
    set keyFound to false
    repeat with topic in theStructuredList
    if item 1 of topic is equal to parentKeyword then
    copy aKeyword to the end of item 2 of topic
    set keyFound to true
    end if
    end repeat
    if keyFound is false then
    copy {parentKeyword, {aKeyword}} to the end of theStructuredList
    end if
    end if
    end if
    end try
    end repeat
     
    repeat with theLine in theStructuredList
    set theKeywordsLine to ""
    repeat with theWord in item 2 of theLine
    set theKeywordsLine to theKeywordsLine & theWord & ", "
    end repeat
    set theKeywordPhrase to theKeywordPhrase & item 1 of theLine & " > " & text 1 thru -3 of theKeywordsLine & return
    end repeat
     
     
    return theKeywordPhrase
    end makeKeywordPhrase
     
    on makeRating(aRating)
    set theStars to ""
    repeat with i from 1 to aRating
    set theStars to theStars & "★"
    end repeat
    return theStars
    end makeRating
     
    -- Le projet est nommé du nom du dossier contenant la photo
    on getProject(thePath)
    set textFilep to POSIX file thePath as alias
    tell application "Finder"
    set theName to name of folder of textFilep
    return theName
    end tell
    end getProject
     
    on makeColorTag(aColorTag)
    if aColorTag = 0 then
    return ""
    else if aColorTag = 1 then
    return "🔴"
    else if aColorTag = 2 then
    return "🟠"
    else if aColorTag = 3 then
    return "🟡"
    else if aColorTag = 4 then
    return "🟢"
    else if aColorTag = 5 then
    return "🔵"
    else if aColorTag = 6 then
    return "🌸"
    else if aColorTag = 7 then
    return "🟣"
    end if
    end makeColorTag

     

    0
  • Zdeněk Macháček

    Thanks. I have came to same conclusion. 

    0
  • Hugues

    A follow-up on your question: after me checking, C1 does keep the name of the lens in its internal database, which could be interrogated with the proper SQLite request. But not directly from the AppleScript Dictionnary. Check a utility  such as DB Browser for SQlite to see the structure and tests some requests.

    0
  • Zdeněk Macháček

    Hi, thanks. I have solved it with "brute force". A few ifs based on focal length - my lenses focal length don't over lap. In case I want to go deeper, then I will use Exiftool

    0

Please sign in to leave a comment.