Bookends Citation Import

The “Import from Bookends” feature is very useful. However, when it imports a reference, it always labels the references by the title of the book/article. Is there a way to change this? Ideally, I would like it to import the references by some sort of scheme that ensured that each reference title would be unique and obvious, i.e. Author Last_Date_a,b,c… or something like that. I have searched the forums for both Bookends and Devothink as well as examining all the preferences I can find to no avail. There is a bookends preference that allows you to alter the format of the exported citation but this does not change the title that Devonthink assigns to the imported note.

I too would love some added functionality in this regard.

For instance, the ability to add the author’s name - since this is mostly how I think of the data, more so that by the name of the article/document…

And if one could somehow leverage some more information, like reference type (to allow sorting by books/journals etc.), it would be amazing. I realise this depends largely on what BE can output - but if the Devonthink people gave us an idea about what would be required - we could lobby for it over on the BE forums, with Jon.

This should be pretty easily scriptable but I can’t offer any help myself as I don’t have a copy of Bookends.

On that note … DT needs metadata for records. This would open up so many possibilities like these.

Even Scrivener has meta-data fields and they are so easy to add.

Screen Shot 2015-06-01.jpg

(Apart from the fact that they are not very useful in Scrivener because of the the complete lack of Applescript support. Building any kind of workflow that is not standard in Scrivener involves some serious hacking with the xml files and the underlying database either falls apart or becomes like sludge by the time you add a few thousand records)

Frederiko

Does anyone know how Devonthink is actually handling the import? Is it really just a script that has been ‘baked in’ to the program or is it something else altogether? If I could figure out what is driving the current behavior it seems like it shouldn’t be all that difficult to alter that behavior. I also posted about the Evernote import, which seems to have some functionality in common. Are both of these at root some sort of script? If so, where could that script, (even if hidden) be found?

It’s a plugin sending AppleEvents to Bookends and therefore not customizable. However, it’s similar to this former script:


-- Import references from Bookends
-- Created by Christian Grunenberg on Fri Jun 15 2012.
-- Copyright (c) 2012. All rights reserved.

property pFormat : "Summary" -- "Summary" or "Ref with Abstract" (the third line contains the title in both cases)

tell application id "DNtp"
	activate
	try
		set theGroups to {"All", "Hits", "Attachments", "Selection"}
		set theUserGroups to ""
		
		try
			-- Requires Bookends 11.3.2
			tell application "Bookends" to set theUserGroups to «event DNtpRGPN»
		end try
		
		if theUserGroups is not "" and theUserGroups is not missing value then
			if theUserGroups is equal to "No Bookends library window is open." then error theUserGroups
			set {od, text item delimiters of AppleScript} to {text item delimiters of AppleScript, ASCII character 13}
			set theUserGroups to text items of theUserGroups
			set text item delimiters of AppleScript to od
			set theGroups to theGroups & theUserGroups
		end if
		
		choose from list theGroups with prompt "Select the group to import"
		if the result is not false then
			set theGroupName to item 1 of the result
			tell application "Bookends" to set theIDs to «event DNtpRUID» theGroupName
			
			set {od, text item delimiters of AppleScript} to {text item delimiters of AppleScript, ASCII character 13}
			set theIDs to text items of theIDs
			set text item delimiters of AppleScript to od
			
			if theIDs is not {} then
				show progress indicator "Importing…" steps (count of theIDs)
				set theGroup to get record at "/Bookends"
				if not (exists theGroup) then
					set theGroup to create location "/Bookends"
					set exclude from tagging of theGroup to true
					(* try
						set thePath to POSIX path of (path to me)
						set pathToIcon to thePath & "Contents/Resources/bookends_128.icns"
						set thumbnail of theGroup to pathToIcon
					end try *)
				end if
				repeat with theID in theIDs
					set theURL to "bookends://sonnysoftware.com/" & theID
					if not (exists record with URL theURL) then
						try
							tell application "Bookends"
								set theRTF to «event DNtpGUID» theID given «class RRTF»:"true", string:pFormat
								try
									set theName to «event DNtpRFLD» theID
								on error
									set theName to ""
								end try
							end tell
							set theRecord to create record with {name:theName, type:rtf, content:theRTF, URL:theURL} in theGroup
							if theName is missing value or theName is "" then
								set theName to (paragraph 3 of rich text of theRecord)
								set name of theRecord to theName
								set theName to name of theRecord
							end if
							step progress indicator theName
						on error
							step progress indicator
						end try
					else
						step progress indicator
					end if
				end repeat
				hide progress indicator
			else
				error "Nothing to import."
			end if
		end if
	on error error_message number error_number
		hide progress indicator
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell