Repeat over files in a File > Open dialog with Applescript

Posted by GotNoSugarBaby on Stack Overflow See other posts from Stack Overflow or by GotNoSugarBaby
Published on 2013-06-30T18:31:03Z Indexed on 2013/07/01 10:21 UTC
Read the original article Hit count: 209

Filed under:
|
|

In the below script I use an Application other than Finder to launch an "Open" browser and perform a search in it.

I've got the window into the state I want, but whatever I try can't access the list of files to repeat over.

If anyone can help by adding the code to repeat over that file list and log out the file path of each file it'd be a huge help.

Thanks a lot.

preview with an "open file" dialog active, with a search performed

tell application "Preview"

  -- start the app
  activate

  -- let it boot up
  delay 3

  -- ensure it still has focus
  activate

end tell

tell application "System Events"

  tell process "Preview"

    -- spawn "Open" window
    keystroke "o" using {command down}
    delay 0.5

    -- spawn "Go to" window
    keystroke "g" using {command down, shift down}
    delay 0.5

    -- expand scope of search to all of this mac
    keystroke "/"
    keystroke return
    delay 0.5

    -- spawn search field
    keystroke "f" using {command down}
    delay 0.5

    -- perform search
    keystroke ".jpg OR .jpeg"
    keystroke return

  end tell

end tell

© Stack Overflow or respective owner

Related posts about dialog

Related posts about applescript