REQUIRED PROGRAM: -- BibDesk
This script copies to the clipboard a MultiMarkdown (MMD) cite key for an item in your BibDesk library. The script will present a dialog box with all of your BibDesk groups, and then, once you select a group, of all the items in that group. When you select an item, its cite key is copied to the clipboard, so that you can insert it into any text editor or word processor. The format of the cite key is: [pp. __][#CiteKey]
tell application "BibDesk"
set allDocs to every document of application "BibDesk"
set listofDocs to {}
repeat with theDoc in allDocs
set thename to the name of theDoc
copy thename to the end of listofDocs
end repeat
if (not ((count of listofDocs) is 1)) then
set SelDoc to choose from list of listofDocs with title "Select BibDesk Database" with prompt ¬
"Current BibDesk Databases" OK button name "OK"
set theDoc to item 1 of SelDoc
else
set theDoc to document 1 of application "BibDesk"
end if
set allGroups to every static group of theDoc
if (not allGroups is {}) then
set listofGroups to {}
repeat with theGroup in allGroups
set thename to the name of theGroup
copy thename to the end of listofGroups
end repeat
set SelGroup to choose from list of listofGroups with title "Select BibDesk Group" with prompt ¬
"Current BibDesk Groups" OK button name "OK"
set theGroup to item 1 of SelGroup
set allPubs to every publication of group theGroup of theDoc
else
set allPubs to every publication of theDoc
end if
set listofPubs to {}
set listofCites to {}
repeat with thePub in allPubs
set PubName to title of thePub
copy PubName to the end of listofPubs
set CiteKey to cite key of thePub
copy CiteKey to the end of listofCites
end repeat
set SelPub to choose from list of listofPubs with title "Select BibDesk Publication" with prompt ¬
"Current BibDesk Publications" OK button name "OK"
set thePub to SelPub as string
set PubPlacement to my findAll(listofPubs, thePub) as number
set PubCite to item PubPlacement of listofCites
set FinalText to "[pp. __][#" & PubCite & "]"
end tell
set the clipboard to FinalText
on findAll(lst, val)
-- HAS (http://applemods.sourceforge.net/mods/Data/List.php)
local lst, val, res
try
if lst's class is not list then error "not a list." number -1704
if {val} is not in lst then return {}
set res to {}
script k
property l : lst
end script
repeat with i from 1 to count of k's l
if k's l's item i is val then set res's end to i
end repeat
return res
on error eMsg number eNum
error "Can't find All: " & eMsg number eNum
end try
end findAll