0 Replies Latest reply on Jan 7, 2013 2:57 PM by Roger_1

    Running Apple Script

    Roger_1

      Title

      Running Apple Script

      Post

            

                           

                                         I got this script to do what I wanted but I don't like having to use the clipboard although it's not a major problem.

                                         The scrip takes the path from a filemaker pro field and converts it, then calls exiftools with that path to get the creation date of the image. I only need the last 19 characters of the return from exiftools. Then paste that date into another field.

                                         I would appreciate suggestions on how to improve the script or maybe a different approach.

                                         Thanks

                                         Roger

      #

                                          

                                          

      #Convert file path

      Set Variable [ $FilePath; Value:RWellsImages::FilePath ]

      Set Variable [ $FilePath; Value:Substitute ( $FilePath; "file://" ; "/Volumes/" ) ]

      Set Field [ RWellsImages::WorkField; $FilePath ]

      #copy file path to clipboard for use in applescript

      Copy [ RWellsImages::WorkField ] [ Select ]

      #

      #run apple script and exiftool

      Perform AppleScript [ Native AppleScript: -- get file
                                         set FilePath to the clipboard
                                         set FilePath to quoted form of POSIX path of FilePath

      set TheScript to ""

      -- set script
                                         set TheScript to "exiftool -CreateDate -MetadataDate " & FilePath
                                         -- run script
                                         set ScriptResult to do shell script TheScript 
                                         display dialog ScriptResult
                                         set the clipboard to ScriptResult ]

      #

      #paste clipboard to work field then select only the last 19 characters for the date and time.

      Paste [ RWellsImages::WorkField ] [ Select ]

      Set Field [ RWellsImages::When; Right ( RWellsImages::WorkField ; 19) ]