How to find out which file triggered an action from spotlight 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 user@host.inetloc 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.
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.