DT3 and Bibdesk

Just cooked up this which is a bit more elegant IMHO. This does require you to set up an exportMarkdown template in BibDesk first. Or you can comment out those two lines. Next steps would be to add existing BibDesk URLs and linked files as well.

    tell application "BibDesk"
	set s to selection of document 1
	repeat with i in s
		
		-- get the cite key and create a new DT group with the same name and a link back to the BD record
		set ck to cite key of i as string
		set c to ""
		-- get the markdown citation
		export document 1 using template "exportMarkdown" to clipboard for i
		set c to the clipboard
                -- create the new group
		tell application id "DNtp"
			tell think window 1 to set myGroup to create location ck
			add custom meta data ck for "Cite Key" to myGroup
			add custom meta data "x-bdsk://" & ck for "BibDesk URL" to myGroup
			-- add the markdown citation to the new group
			create record with {name:ck & " Markdown reference", plain text:c, type:markdown} in myGroup
			
			-- get the DT link to add to the BD record
			set theDntp_Link to reference URL of myGroup
		end tell
		
		-- get all the fields from the BD item
		set theFields to fields of i
		
		-- add them all to the new DT group
		repeat with f in theFields
			set fn to name of f
			set fv to the value of f
			tell application id "DNtp"
				add custom meta data fv for fn to myGroup
			end tell
		end repeat
		
		-- add the DT link to BibDesk
		add theDntp_Link to i
	end repeat
end tell
1 Like