To get a very useful x-scrivener-item link with an id reference to the current text/note, we can use the Scrivener menu path:
Edit > Copy Special > Copy Document as External Link
but the menu item is only enabled when:
- The binder panel is visible at left, and
- the item for which a link is needed is selected in the binder.
A suggestion (and, in the interim) a script.
Suggestion:
- Perhaps enable copying of an
x-scrivener-item
link with id to whichever text/note currently has editing focus ? - perhaps also enable a variant which copies a full Markdown link, including a label taken from the text’s binder name ?
For example, where the binder item has the name Abstract.
[Abstract](x-scrivener-item:///Users/houthakker/Desktop/sample.scriv?id=30B2E82B-39E4-421C-B528-A1943A472A21)
Script:
In the meanwhile, here is a script (I have just posted a variant of it on the Hook forum) which aims to:
- Ensure that the binder is open and has focus, and
- copy both item and name and x-scrivener-item link to the clipboard in the Mardkown format.
Depending on your system you may (as this script depends on UI scripting) need to slightly increase the delay values in the script.
(Could be assigned to a shortcut key with Keyboard Maestro or FastScripts etc)
[code]-- Rob Trew 2020
– Ver 0.01
tell application “Scrivener” to activate
tell application “System Events”
set ps to processes where its name is “Scrivener”
if {} ≠ ps then
set menuBar to menu bar 1 of (item 1 of ps)
-- FOCUS TO BINDER
set focusBinder to menu item "Binder" of menu 1 of ¬
(menu item "Move Focus To" of (menu "Navigate" of menuBar))
if enabled of focusBinder then
click focusBinder
else
-- The Show Binder / Hide Binder label state is not always quite as expected.
click (first menu item of (menu "View" of menuBar) ¬
where name ends with "Binder")
delay 0.1
click focusBinder
delay 0.1
end if
-- NAME COPIED
set menuEdit to (menu "Edit" of menuBar)
click (menu item "Copy" of menuEdit)
delay 0.2
set strName to the clipboard
-- URL COPIED
click (menu item "Copy Document as External Link" of menu ¬
of (menu item "Copy Special" of menuEdit))
delay 0.2
set mdLink to "[" & strName & "](" & (the clipboard) & ")"
set the clipboard to mdLink
return mdLink
else
""
end if
end tell[/code]