DEVONthink assigns a custom Uniform Resource Locator ( URL) to every file that is in a DEVONthink database. An example of this URL is the following:

x-devonthink-item://F860B6A7–2AF7–4938–9C64-FFA0CC59036E

These URLs are extremely useful because you can use them to create links to the respective files of any type (e.g. RTF, HTML, Markdown). Moreover, they have some distinct advantages compared to links based on file paths. Specifically, the URL does not change if you rename the file or move it to another database or group/folder. You can even sync the file with a DEVONthink database on another device (iOS or macOS), and its URL remains the same. As a result, you can be confident that the links will not break in the future.

Moreover, in the case of a PDF file, a different URL is assigned to every single page of it. Consequently, you can link to a specific PDF page which is extremely useful for scholarly purposes. An example of such URL is the following:

x-devonthink-item://F860B6A7–2AF7–4938–9C64-FFA0CC59036E?page=10

The index base for the page numbers is zero. As a result, the above URL links to the eleventh page of the document and not to the tenth page as someone could expect.

You can get this URL on the clipboard by using the menu command “Copy Item Link”


or by using the contextual menu (right-clicking on any page).


Then you can just paste the page link in any program that supports RTF (Nisus Writer Pro, Skim notes, Tinderbox notes) and you will get automatically a nicely formatted link.


If you paste the link in Microsoft Word or any plain text editor, you get just the raw link. However, you can create the link manually using either a markup language (Markdown, LaTeX, HTML) or the command “Hyperlink…” in Word.

2017-04-28_17-04-41.jpg
2017–04–28_17–04–41.jpg

The automatically generated link is nice, but it does not contain the linked page number. Also, you cannot get the link to only one file at a time. These limitations can be overcome as usually by using AppleScript.

My preferred link style for non-academic purposes is (Title – Author: Referred Page) or (Title – Author).


The script for creating a link to a PDF page formatted as above is the following:

(*
johnsidi.com
Title: DEVONthink - clipboard - Create RTF link for selected file
Version: 1.0
Date: 28 April 2017
// REQUIREMENTS
--one and only one item should be selected in DEVONthink
*)
set the clipboard to ""
tell application "DEVONthink Pro"
    activate
    set theSelection to the selection
    if theSelection is {} then error "Please select one file."
    set selectedItems to count theSelection
    if selectedItems > 1 then error "Please select only one file"
    set fileType to kind of content record of window 1
    set fileLink to the reference URL of content record of window 1
    set nameFile to name of content record of window 1
    if fileType is equal to "PDF+Text" or fileType is equal to "PDF" then
        set DEVONthinkPageNum to current page of window 1
        set realCurrentPageNum to DEVONthinkPageNum + 1
        set HTMLlink to "(" & nameFile & ": " & realCurrentPageNum & ")"
        set the clipboard to HTMLlink
        do shell script "pbpaste | textutil -stdin -format html -convert rtf -stdout | pbcopy -Prefer rtf"
    else
        set HTMLlink to "(" & nameFile & ")"
        set the clipboard to HTMLlink
        do shell script "pbpaste | textutil -stdin -format html -convert rtf -stdout | pbcopy -Prefer rtf"
    end if
end tell

The script for creating links to the selected items in DEVONthink is the following:

(*
johnsidi.com
Title: DEVONthink - clipboard - Create RTF links for selected files
Version: 1.0
Date: 28 April 2017
// REQUIREMENTS
--at least one file should be selected in DEVONthink
*)
set the clipboard to ""
tell application "DEVONthink Pro"
    activate
    set theSelection to the selection
    if theSelection is {} then error "Please select at least one file."
    repeat with anItem in theSelection     
        set fileType to kind of anItem
        set fileLink to the reference URL of anItem
        set nameFile to name of anItem
        set HTMLlink to "(" & nameFile & ")
" set the clipboard to (the clipboard) & HTMLlink & return end repeat do shell script "pbpaste | textutil -stdin -format html -convert rtf -stdout | pbcopy -Prefer rtf" end tell