Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kasibaldus

macrumors newbie
Original poster
Mar 3, 2017
2
0
Hey Guys!

I cant get that AppleScript to work in Automator.
It opens a Dialog, i can choose the Pictures to process, but fails at calling the exiftool shell script.
I dont get it, how to hand over the files to exiftool.
Could you guys take a look at it?

Thanks in advance!

Code:
on run {input, parameters}
    
    
    
    set theImages to choose file with prompt "Please select some images to process:" of type {"public.image"} with multiple selections allowed
    
    -- Update the initial progress information
    set theImageCount to length of theImages
    set progress total steps to theImageCount
    set progress completed steps to 0
    set progress description to "Processing Images..."
    set progress additional description to "Preparing to process."
    
    repeat with a from 1 to length of theImages
        
        -- Update the progress detail
        set progress additional description to "Processing image " & a & " of " & theImageCount
        
        -- Process the image
        do shell script "/usr/local/bin/exiftool -overwrite_original -IFD0:OpcodeList3= " & theImages
        -- Increment the progress
        set progress completed steps to a
        
        -- Pause for demonstration purposes, so progress can be seen
        delay 1
    end repeat
    
    -- Reset the progress information
    set progress total steps to 0
    set progress completed steps to 0
    set progress description to ""
    set progress additional description to ""
    
    
    
    return input
end run
 

kryten2

macrumors 65816
Mar 17, 2012
1,115
99
Belgium
theImages is a list of aliases. Exiftool needs POSIX paths to work with. You're also feeding exiftool the whole list perhaps you need to feed it an item from the list.

Code:
set theImages to choose file with prompt "Please select some images to process:" of type {"public.image"} with multiple selections allowed

-- Update the initial progress information
set theImageCount to length of theImages
set progress total steps to theImageCount
set progress completed steps to 0
set progress description to "Processing Images..."
set progress additional description to "Preparing to process."

repeat with a from 1 to length of theImages
  
   -- Update the progress detail
   set progress additional description to "Processing image " & a & " of " & theImageCount
  
   -- Process the image
   --do shell script "/usr/local/bin/exiftool -overwrite_original -IFD0:OpcodeList3= " & theImages
   -- Log the POSIX path of the items in the list theImages
   log quoted form of POSIX path of item a of theImages
   -- Increment the progress
   set progress completed steps to a
  
   -- Pause for demonstration purposes, so progress can be seen
   delay 1
end repeat

-- Reset the progress information
set progress total steps to 0
set progress completed steps to 0
set progress description to ""
set progress additional description to ""

Replies:
Code:
tell application "Script Editor"
    choose file with prompt "Please select some images to process:" of type {"public.image"} with multiple selections allowed
        --> {alias "VMWareYosemite:Users:kryten:Documents:ScreenGrab2.png", alias "VMWareYosemite:Users:kryten:Documents:ScreenGrab.tiff"}
end tell
(*'/Users/kryten/Documents/ScreenGrab2.png'*)
(*'/Users/kryten/Documents/ScreenGrab.tiff'*)
 
Last edited:

Kasibaldus

macrumors newbie
Original poster
Mar 3, 2017
2
0
theImages is a list of aliases. Exiftool needs POSIX paths to work with. You're also feeding exiftool the whole list perhaps you need to feed it an item from the list.

Code:
   --do shell script "/usr/local/bin/exiftool -overwrite_original -IFD0:OpcodeList3= " & theImages
   -- Log the POSIX path of the items in the list theImages
   log quoted form of POSIX path of item a of theImages

Great! Thanks for the Hint. Got it working with the following Code.
Only thing thats missing, is the "progress". I can not get it to display the progress.
Is there somewhere a "display" command missing ? I think "display" is only for dialogs?

Code:
set theImages to choose file with prompt "Please select some images to process:" of type {"public.image"} with multiple selections allowed
   
   -- Update the initial progress information
   set theImageCount to length of theImages
   set progress total steps to theImageCount
   set progress completed steps to 0
   set progress description to "Processing Images..."
   set progress additional description to "Preparing to process."
   
   repeat with a from 1 to length of theImages
       
       -- Update the progress detail
       set progress additional description to "Processing image " & a & " of " & theImageCount
       
       -- Process the image
       do shell script "/usr/local/bin/exiftool -overwrite_original -IFD0:OpcodeList3= " & quoted form of POSIX path of item a of theImages
       -- Increment the progress
       
       set progress completed steps to a
       
       -- Pause for demonstration purposes, so progress can be seen
       delay 1
   end repeat
   
   -- Reset the progress information
   set progress total steps to 0
   set progress completed steps to 0
   set progress description to ""
   set progress additional description to ""
 

kryten2

macrumors 65816
Mar 17, 2012
1,115
99
Belgium
If your script is running in the Script Editor, progress indicators appear in the script window. If your script is running from the Script Menu, progress indicators appear in the Automation Menu in the main menu bar. And if your script is saved as an applet, a floating progress window appears automatically (like the one in the movie below).

Don't know how Automatic Progress Indicators show progress when run from a Run Applescript action inside Automator.

Info: https://macosxautomation.com/yosemite/index.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.