Integrating Bookends, Scrivener and Devonthink
Posted: Thu Nov 21, 2013 4:43 pm
Taking up my own suggestion (viewtopic.php?f=2&t=3444) I have written an applescript in order to integrate my wordprocessor of choice (Scrivener) with DevonthinkProOffice and Bookends more closely (borrowing from several other scripts, especially from this http://forum.devontechnologies.com/view ... 20&t=18047 by Korm). Often it is the case that I do not remember what the cited reference was exactly about. This script automatically links the references in Scrivener to Bookends and – when the respectivce link in Bookends is present (see my script here: viewtopic.php?f=6&t=3454) - also to the document in DTPO. Then only the reference has to be clicked to find the entry in Bookends (or DTPO).
It will copy the selected reference in Bookends, switch to Scrivener and paste the unformatted reference to the cursor position. In doing this it will link the Bookends-ID to Bookends and the group "Author Year" to DTPO (I store the DTPO-reference-URL in Bookends in userfield 20).
The unformatted link looks a little bit different than the normal output from Bookends, but Bookends does not seem to have a problem to still identify the correct reference when formatting the bibliography. However, before the final Scan-command can be invoked the document has to be stripped from all hyperlinks. The easiest way to do this seems to be in Microsoft Word (select all and then cmd-6) but I would be eager to hear about other solutions.
My only aesthethic problem with the script is that diacritic letters look awful. Somewhere along the script letters like "ä", "ö", "ø" etc. are changed in something like "ö", despite the fact that the shell script retains the RTF-format. Perhaps anyone knows of an easy way to remedy this?
Cheers,
Nils
It will copy the selected reference in Bookends, switch to Scrivener and paste the unformatted reference to the cursor position. In doing this it will link the Bookends-ID to Bookends and the group "Author Year" to DTPO (I store the DTPO-reference-URL in Bookends in userfield 20).
The unformatted link looks a little bit different than the normal output from Bookends, but Bookends does not seem to have a problem to still identify the correct reference when formatting the bibliography. However, before the final Scan-command can be invoked the document has to be stripped from all hyperlinks. The easiest way to do this seems to be in Microsoft Word (select all and then cmd-6) but I would be eager to hear about other solutions.
My only aesthethic problem with the script is that diacritic letters look awful. Somewhere along the script letters like "ä", "ö", "ø" etc. are changed in something like "ö", despite the fact that the shell script retains the RTF-format. Perhaps anyone knows of an easy way to remedy this?
Cheers,
Nils
Code: Select all
tell application "Bookends"
set theIDString to «event DNtpRUID» "selection"
set theauthor to «event ToySRFLD» theIDString given string:"authors"
set theyear to «event ToySRFLD» theIDString given string:"thedate"
set devonthinkReference to «event ToySRFLD» theIDString given string:"user20"
set authorYear to theauthor & ", " & theyear as string
if devonthinkReference is "" then
set theReference to "{" & authorYear & ", #" & ("<font face=\"times new roman\"><a href=\"" & "bookends://sonnysoftware.com/" & theIDString & "\">" & theIDString & "</a></font>") & "}"
else
set theReference to "{" & ("<font face=\"times new roman\"><a href=\"" & devonthinkReference & "\">" & authorYear & "</a></font>") & ", #" & ("<font face=\"times new roman\"><a href=\"" & "bookends://sonnysoftware.com/" & theIDString & "\">" & theIDString & "</a></font>") & "}"
end if
set RTFtheReference to (do shell script "echo " & quoted form of theReference & " | textutil -stdin -stdout -format html -convert rtf | pbcopy -Prefer rtf")
end tell
tell application "Scrivener"
activate
end tell
tell application "System Events"
key code 9 using {command down} -- v key
end tell