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/
use framework "Foundation"
set p to POSIX path of (input)
set nsu to current application's |NSURL|'s fileURLWithPath:p
return nsu's fileReferenceURL()
consider that input might contain a list of items.
In this case either use a repeat loop to collect all items or an index e.g. item 1 of to get a specific item
Thanks for the fix. Now it does not return anything yet. If i return p it copies the full path to clipboard, but using nsu’s fileReferenceURL() does not produce anything. Ideas?