0

I would like to set the default file association for a file type (PDF) to an Apple Script app. The Apple Script app will open the file type on a remote machine (using remote Apple events) with a specific app (Preview.app). Not that it matters but, the remote machine is a virtual machine on the local machine. I think the script should look something like this:

set remoteMachine to "eppc://elcapitan.local"
tell application "finder" of machine remoteMachine
    open ("/Applications/Preview.app" as POSIX file as alias)
end tell

set pathToLocalOnRemote to "/Volumes/cajal"
repeat with fn in argv
    tell application "Preview" of machine remoteMachine
        open pathToLocalOnRemote & fn
    end tell
end repeat

What is not clear to me is, what actually happens when a file type (PDF) is opened in the Finder? The default file association will specify which app to use. Inside the app, is there just a binary that is called which gets a list of file names as its argument? If so, is this binary just like some command line binary? In sum, can I trust Finder will execute my script by something analogous to a command line call with a list of files as the argument? Also, will the file name list be given as the (full) absolute path?

  • It's really unclear what you're asking. Your post title indicates one query about setting a default opener for a file type; your post suggests you want help writing the script that processes that file type; then you seem to actually be wanting to know the specifics of what happens under-the-hood. It's not that any of these are bad questions, per se, but more that it reads as if you don't know what you want to ask, and therefore I (and undoubtedly others) don't know where to begin. I recommend editing and being clear and concise what your actually question is. – CJK Jun 17 at 0:39
  • As for this question: "can I trust Finder will execute my script by something analogous to a command line call with a list of files as the argument?", I would say the best answer will come from trying it and seeing what happens. – CJK Jun 17 at 0:41

You must log in to answer this question.

Browse other questions tagged .