AppleScript and Automator. Pls help!

Discussion in 'Mac Programming' started by Kasibaldus, Mar 3, 2017.

  1. Kasibaldus macrumors newbie

    Joined:
    Mar 3, 2017
    #1
    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
     
  2. kryten2, Mar 3, 2017
    Last edited: Mar 3, 2017

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    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'*)
    
     
  3. Kasibaldus thread starter macrumors newbie

    Joined:
    Mar 3, 2017
    #3
     
  4. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    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
     

Share This Page