Blogger Euboulides is creating a very useful series describing a research workflow that incorporates DEVONthink, Skim, scripts, and other techniques. Worth the read, IMO.
I have ready Euboulides’ posts in the meantime and it’s a really interesting approach!
Being able to hyperlink every citation in the written document with the original source and or the personal note in DTPro where it comes from would be great!
I all and thanks to Eubolides: I have been looking for something similar for months! I slightly modified it’s scripts to my needs. As I’m an almost 0-scripter it could be made more elegant and smart: any help appreciated (See notes below)
The first following script get the url of a pdf selected in DT and makes a new note in Skim. The second gets all notes in skim and makes new records in DT (the URL of each record is set to the page number of the pdf)
New note in skim containing DT Pdf URL:
-- Orig. script by Eubolides from: http://organognosi.blogspot.com/
-- Use at your own risk!
tell application id "com.devon-technologies.thinkpro2"
set these_items to the selection
if these_items is {} then error "Please select some contents."
repeat with this_item in these_items
set RecordLink to the reference URL of this_item
set DevonThinkLink to RecordLink & "?page=0"
set PdfPath to get the path of this_item
set PdfName to the name of this_item
tell application "Skim"
open PdfPath
tell page 1 of document 1
make note with properties {type:anchored note, bounds:{523, 760, 540, 760}, text:DevonThinkLink, extended text:PdfName}
end tell
save document 1
--delay 1
--close document 1
end tell
end repeat
end tell
Notes from skim to DT:
tell application "Skim"
set pdfDevonThinkLink to (get text for note 1 of document 1) as string
set pdfDevonThinkLinkWihtoutZero to replaceText(pdfDevonThinkLink, "=0", "=") of me
set allMyNotes to notes of document 1
set numberOfMyNotes to length of allMyNotes as integer
repeat with currentNumber from 0 to numberOfMyNotes
set pdfText to (get text for note currentNumber of document 1) as string
set pageOfNote to the index of page of note currentNumber of document 1
set pageForDevonThinkLink to pageOfNote - 1
set the clipboard to pdfText
tell application id "com.devon-technologies.thinkpro2"
set thisNotes to (the clipboard) & " [" & pdfDevonThinkLinkWihtoutZero & pageForDevonThinkLink & " p. " & pageOfNote & "]"
create record with {name:"SkimNotes", rich text:thisNotes, type:rtf, URL:pdfDevonThinkLinkWihtoutZero & pageForDevonThinkLink} in inbox
end tell
end repeat
end tell
on replaceText(thisText, searchString, replacementString)
set AppleScript's text item delimiters to the searchString
set the itemList to every text item of thisText
set AppleScript's text item delimiters to the replacementString
set thisText to the itemList as string
set AppleScript's text item delimiters to {""}
return thisText
end replaceText
Second script places every skim note in Global inbox and the note looks like that:
The page URL of the pdf is referenced as a URL in the URL field of the record but it would be great if it could be presented as a clickable url in the text of the record showing the page number:
instead of
Can somebody collaborate?
Finally I have a couple more questions:
could it be possible to place new records in a specifically newly created folder named after the file name?
the name of new records is the same for every created record, how could it be make sequential (something like “MyNotes 01”, etc.)?
what about changing the icon of newly created record? [At present I have a specific script which I run after the whole process to apply an icon that means to me “notes”]
The script looks like that:
credits: Johannes Hoffmann
using terms from application "DEVONthink Pro"
tell application "DEVONthink Pro"
try
if not (exists think window 1) then error "No window is open."
set this_selection to the selection
repeat with this_item in this_selection
set cPath to ""
set cIcon to ""
--set aTags to tags of this_item
set cType to type of this_item
if cType is not group then
set cIcon to "61581E3C-8BF2-4D74-A788-6149C983FC94"
end if
if cIcon is not "" then
set cPath to path of (get record with uuid cIcon)
set thumbnail of this_item to cPath
end if
end repeat
on error error_message number error_number
if the error_number is not -128 then
try
display alert "DEVONthink Pro" message error_message as warning
on error number error_number
if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
end try
end if
end try
end tell
end using terms from
My version (I’ve absolutely no experience with AppleScript-Programming ) has the advantage, that for the created rtf notes the url points to the original pdf file which can be opened in the external viewer (in my case Skim) by clicking it.
for your script, in the url fields the selected text in Skim is inserted and not a url to the pdf file…
The devonthink hyperlinks inserted in the rtf file by your script are not clickable for me (just plain text, no link).
I’m also very interested in the answers to your questions.
Hi Elwood,
thanks for sharing too. Actually I tried your script before modifying the above scripts: I find more useful (at least to me!) making all the note-taking process in skim and then export everything in DT. The advantage of exporting skim notes (and not selected text from the pdf) is that the skim note can contain, beside the quote, also my comments (ie. the quote and the reason why I’m taking the specific note on that passage). The link (in the url field of the DT record) points directly to the page of the pdf and not only to the file: even though the file link gives you the opportunity to open it externally, I prefer having the right page of the quote as link.
I’m not sure I understand what you say: the url in the url field (that appears in the editing bar above the text of record) takes you to the page of the pdf. On the other hand I wasn’t able to paste the url as a clickable link in the text of the record (that one of the issues)
Hope somebody can ‘refine’ the my dumb modified script
maybe I did something wrong, but with your script(s) I get strange results:
I tried it with a pdf document with the first note created with your Script containing as “note title” the DevonThink-URl and as “note content” the Name of the pdf.
The document contains 2 further notes (highlights).
If I launch your second script, it creates 4 RTF docs in the Inbox of my db.
The url of all those 4 docs is the content of the 2nd note (highlight).
The xdevonthink url is only contained in the last (4th) RTF and it is not “clickable”.
In general, you’re right and it seems better doing all the note taking in Skim (at least if one is not as “skilled” as Euboulides knowing how to use a “real wiki”), but at the moment it does not work for me.
The disadvantage of exporting all notes at once (from my point of view) is that I can not see their content for tagging them appropriately.
at the moment I don’t have the time to search for the cause of those problems, as for you it seems to work fine…
I wonder why you refer to “note 4” for catching the url, although your script only creates one note with the devonthink url.