Link directly to file in DT from another program

I saw in some posts that this should be possible from v.2, but from the help it’s not as straightforward. In Evernote I can get a link that when clicked on from other apps opens the note in EN. Can I do that in DT? I want to work in Obsidian but keep the reference image in DT and link right to it instead of having to go to DT and search.
When I copy item link I get: x-devonthink-item://… but this isn’t clickable I dont think, but can be used w/ some script. Can one get a direct link?

I use those x-devonthink-item links from MindNode and OmniOutliner. They are working for me, and are portable. The link works as long as the relevant DT database is on the machine.

Perhaps Evernote is wildcard.

so you are able to click on those links? I’m pasting into an Obsidian note, but it’s just text…

What is it pasting ?
A screen capture would be helpful.

it’s just text, not clickable to open in DT. probably I’m missing something on this this is supposed to work…

Isn’t Obsidian based on Markdown? Don’t you need to format links as such?

1 Like

not sure how it works, but doesn’t work in notepad or any other app … the link is not clickable.

It works in any app that supports rich text (links) (I use this feature all the time in apps like Apple Notes, Things, OmniOutliner, …).

If you are using plain text apps like Obsidian, you need to format your links in Markdown language.

This isn’t really specific to Devonthink links either. If you use plain text, like Obsidian does, you can’t click any link, unless formatted in the correct syntax.

Examples from TextEdit below. First window is plain text, second is richt text.

1 Like

@chrk is correct. What you’re pasting isn’t a clickable Markdown link.

I don’t use Obsidian but I’m curious if you can drag and drop between DEVONthink and it.

As it seems you’re just starting to use Markdown please note:

If you want to use “Markdown” in DEVONthink and Obsidian (or any other app) then it’s a good idea to check how the flavors that each app uses differ.

  • Search the forum for e.g. markdown syntax [app name].
  • Afterwards read the specs. You don’t have to compare everything, compare what you need.

Yes, but as mentioned you need a Markdown link:

[Example](x-devonthink-item://DB06EA1C-4544-4B6D-8FAE-A084EF773A31)

There’s no built-in command to copy such a link but it can be done via script

-- Copy Markdown link

use AppleScript version "2.4"
use framework "AppKit"
use scripting additions

tell application id "DNtp"
	try
		set theRecords to selected records
		if theRecords = {} then error "Please select a record"
		
		set theMarkdownLinks to {}
		
		repeat with thisRecord in theRecords
			set end of theMarkdownLinks to "[" & (name of thisRecord) & "](" & (reference URL of thisRecord) & ")"
		end repeat
		
		if (count theMarkdownLinks) = 1 then
			set theMarkdownLinks_string to item 1 of theMarkdownLinks
		else
			set theMarkdownLinks_string to my tid(theMarkdownLinks, space & space & linefeed)
		end if
		
		my setClipboardToPlainText(theMarkdownLinks_string)
		display notification theMarkdownLinks_string with title "Copied"
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell

on tid(theInput, theDelimiter)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theDelimiter
	if class of theInput = text then
		set theOutput to text items of theInput
	else if class of theInput = list then
		set theOutput to theInput as text
	end if
	set AppleScript's text item delimiters to d
	return theOutput
end tid

on setClipboardToPlainText(theText)
	set thePasteboard to current application's NSPasteboard's generalPasteboard()
	thePasteboard's clearContents()
	(thePasteboard's setString:theText forType:(current application's NSPasteboardTypeString))
end setClipboardToPlainText

3 Likes

thanks. I figured it out now… in text edit I had to highlight and create link. I thought it might be automatic like web links.

this worked in obsidian, i didn’t know that syntax. what is the script to copy the link for? I grab the link via DT “item link” … in what case do you use the script?

Copying a Markdown link whose title is the name of the linked record.

Usage:

  • Select record
  • Run script
  • Go to destination record
  • Paste

Using DEVONthink’s menu Edit > Copy Item Link the steps to create a Markdown link whose title is the record’s name are:

  • Select record
  • Copy record’s name
  • Go to destination record
  • Type [
  • Paste
  • Type](
  • Go back to record
  • Edit > Copy Item Link
  • Go to destination record
  • Paste
  • Type )

I’m a bit confused by that sequence. Doesn’t the link title go in the [] and the link in () for a markdown link?

1 Like

Yes, of course. Thanks!

Was just looking at this. Thank you! Works perfectly.

1 Like