DEVONthink script

In order for DEVONthink to display clickable links, the new document needs to be markdown
link to devonthink forum

So I modified the script in Hook to change the type:txt to type:markdown

Question: how can I copy the markdown link within this script (not using the shortcuts), and THEN paste this in the main body of the new document? [I know I can do this manually, but it takes many steps,

  1. open hook,
  2. then command M which copies the markdown link,
  3. then I open hook again, choose new DEVONthink file using my modified script, run it,
  4. open the devonthink file and
  5. paste in the body

I have also tried to add:
tell application “System Events” to key code 9 using command down
which should be paste from clipboard
cool list of Mac system events
this did not work

Try this Link to New script:

tell application id "DNtp"
	set newItem to create record with {name:"$title", type:markdown, plain text:"[$title]($user_link)"}
	set refURL to reference URL of newItem
	set itemPath to path of newItem
end tell
open location refURL
get refURL

$title is replaced with the title of the source document when the script runs
$user_link is replaced with a link to the source document.

so [$title]($user_link) will be transformed into a markdown link to the source document. E.g. [DEVONthink script - Discussion & Help - Hook Productivity Forum](https://discourse.hookproductivity.com/t/devonthink-script/1242)

You can specify the plain text contents of a new record created with AppleScript, so
set newItem to create record with {name:"$title", type:markdown, plain text:"[$title]($user_link)"}
will create a new record with a markdown link to the source document, which, if I understand correctly, is what you’re trying to do.

Hope this helps!

3 Likes

Thank you, this was just what I needed, only a year later LOL.

1 Like