I've created an applescript application (in automator) to open ssh urls. The application is bound to the ssh:// url.

I've got a lot of [email protected] files and search these in spotlight. Selecting the file from spotlight opens the associated application, but i cannot figure out what the filename is which triggered the opening of the application.

It works if i add the "get selected finder items" action and open the .inetloc file from the finder.

I've searched the net and the applescript reference, but it's just too specific.

  • How exactly is your app bound to ssh URLs? Info.plist hacking?
    – kopischke
    Commented May 25, 2012 at 8:25
  • It's bound by using the "Deault Apps" preference pane.
    – michiel
    Commented May 29, 2012 at 6:07
  • And is it bound to the ssh protocol (i.e. on the URL tab of RCDefaultApp) or to the .inetloc file extension?
    – kopischke
    Commented May 30, 2012 at 15:00
  • It is bound to the protocol
    – michiel
    Commented May 31, 2012 at 6:12
  • OK, getting closer. Could you post details of what the Automator app does when called (workflow actions with respective settings, script contents if there are script actions), please? I think I may have an answer for you, but I could be wrong and need to check the specifics.
    – kopischke
    Commented May 31, 2012 at 6:39

1 Answer 1


Would something like this work for you:

on run argv
    set theFile to (item 1 of argv)
    set theFilePath to quoted form of POSIX path of theFile 
    -- your script using the parameters follows
end run

You could skip the first line and just pull off the path if you don't need to use the file itself later in the script.

Also, you'll really want to get ASObjC Runner to parse files and paths easily for 10.9 and older or BridgePlus for newer os.

  • Would this work if you're creating an application from Automator? I read somewhere that "on run argv" only works when you run your script with osascript. I'm trying to create an application which can be bound as open action to .inetloc files
    – michiel
    Commented May 29, 2012 at 6:18
  • I don't honestly know with the latest automator. This is the only way I know to parse arguments, so you might want to test it before assuming it works. I prefer shell for this sort of job so that's what I typically use.
    – bmike
    Commented May 29, 2012 at 14:45
  • It's not the problem how to parse the path/file but where it's being passed from spotlight to the application :-)
    – michiel
    Commented May 31, 2012 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .