I use BibDesk to manage and create my bibliographies but all my read and annotated PDF files are inside DevonThink. So I wanted an easy and fast way to connect the PDF files with their respective records in BibDesk. Technically I wanted to populate the "local URL" and "local File" columns of BibDesk. Consequently I wrote an AppleScript which does this job :-).
Moreover this AppleScript assigns the tag/keyword "Linked with DevonThink" to the record in which is applied. In order for this script to work properly you just have to select one PDF file in DevonThink and its respective bibliography record in BibDesk.
The AppleScript code is the following:
Moreover this AppleScript assigns the tag/keyword "Linked with DevonThink" to the record in which is applied. In order for this script to work properly you just have to select one PDF file in DevonThink and its respective bibliography record in BibDesk.
The AppleScript code is the following:
--2011-03-08
--http://organognosi.blogspot.com
--the script works only for one PDF file per time
tell application "DEVONthink Pro"
set this_item to the content record of think window 1
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 PdfPath to (POSIX file PdfPath) as alias
tell application "BibDesk"
activate
set these_items to the selection of document 1
repeat with theBook in these_items
add DevonThinkLink to linked URL of theBook
add PdfPath to linked files of theBook
set currentKeywords to get keywords of theBook as string
if (currentKeywords is not "") then
set delimiter to ", "
else
set delimiter to ""
end if
set keywords of theBook to (keywords of theBook & delimiter & "Linked with DevonThink")
end repeat
end tell
end tell
2 comments:
Very nice script :)
I changed it a little bit by:
- not adding the keyword "Linked with DevonThink" in bibtex keywords,
- setting a custom check-box field named "Dtp" that is checked when running the script,
- adding the tag "BibDesk" in DevonThink to the document (since it is not possible to create custom fields in DevonThink).
The third point allows me to quickly check in DevonThink the documents that are filed in BibDesk
I am wondering if a flag or a label would not be better in DevonThink but I prefer to use them for other things.
I also added error messages in case nothing is selected in BibDesk or DevonThink.
Here is my new script:
tell application "DEVONthink Pro"
try
set this_item to the content record of think window 1
if this_item is {} then error "Nothing selected in DevonThink Pro"
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 PdfPath to (POSIX file PdfPath) as alias
set tags of this_item to (tags of this_item) & "BibDesk"
end try
tell application "BibDesk"
activate
try
set these_items to the selection of document 1
if these_items is {} then error "Nothing selected in BibDesk"
repeat with theBook in these_items
add DevonThinkLink to linked URL of theBook
add PdfPath to linked files of theBook
-- set currentKeywords to get keywords of theBook as string
-- if (currentKeywords is not "") then
-- set delimiter to ", "
-- else
-- set delimiter to ""
-- end if
-- set keywords of theBook to (keywords of theBook & delimiter & "Linked with DevonThink")
set value of field "Dtp" of theBook to "1"
end repeat
end try
end tell
end tell
Thanks for your comments and improvements in the script.
Post a Comment