Copy a file's NSURL to clipboard I am trying to do a rather simple thing: in the context menu I want to have an action (e.g. with Automator) that gets and copies the file's NSURL to clipboard.

The solution seems simple, but it does not work (some unspecific error).
Here is what I have so far:

on run {input, parameters}

   set p to POSIX path of (input)
   set nsu to current application's |NSURL|'s fileURLWithPath:p

   return nsu

end run


I am looking to get the file reference URL, like so: file:///.file/id=6571367.2773272/

I am on El Capitan.

Any ideas?
Here is the solution to the issue (from: http://macscripter.net/viewtopic.php?pid=183164#p183164):

use framework "Foundation"

on run {input, parameters}

    set p to POSIX path of (input)
    set nsu to current application's |NSURL|'s fileURLWithPath:p

    set fru to nsu's fileReferenceURL()'s absoluteString() as text

    return fru

end run


I did not check jweak's answer. It may also work, after all.
The poster over at macscripter also mentioned something important: input may contain a list of items (multi-selected).

Hope this helps someone.