AppleScript to copy link of selected file without invoking Hookmark

I would like an AppleScript that will copy a Hookmark link to the selected file in Finder (only one) without invoking the Hookmark window. I will use this copied link in a larger script (that already functions properly).

My attempt resulted in errors.

Can someone provide me the correct syntax?

    tell application "Finder" to set selectedFiles to selection
    tell application "Hookmark"
	set fileLink to bookmark selectedFiles
    end tell
    return fileLink

error “Can’t make «class docf» "1673676980062182.png" of «class cfol» "Downloads" of «class cfol» "com~apple~CloudDocs" of «class cfol» "Mobile Documents" of «class cfol» "Library" of «class cfol» "john" of «class cfol» "Users" of «class sdsk» of application "Finder" into the expected type.” number -1700 from «class docf» “1673676980062182.png” of «class cfol» “Downloads” of «class cfol» “com~apple~CloudDocs” of «class cfol» “Mobile Documents” of «class cfol» “Library” of «class cfol» “john” of «class cfol» “Users” of «class sdsk»

Yes, that will be useful. We provide Shortcuts: Directory of Shortcuts – Hookmark.

We intend to provide one for copying links to the selected files. It will work for one to N files. Anyone who is AppleScript and Shortcuts enabled can do it, but we’ll go ahead and create one.

by the way it compiles. Will return to it.

meanwhile, anyone who wants to experiment with this or other scripts related here: I recommend doing Hook to Copied Link > Script Editor. That will create a new Script Editor file that is hooked to this page. If one wants to take notes, one can do Hook to New > .

2 Likes