Skip to content

Instantly share code, notes, and snippets.

@gglanzani
Last active January 3, 2016 13:39
Show Gist options
  • Select an option

  • Save gglanzani/8471281 to your computer and use it in GitHub Desktop.

Select an option

Save gglanzani/8471281 to your computer and use it in GitHub Desktop.
(*
PapersToBibDesk: To transfer citations from Papers to formatlib and
auto-generate a citekey.
Place this in ~/Library/Scripts/Applications/Papers
Create this folder if necessary.
Select the references you wish to transfer in Papers first.
Then run the script.
Make the pause longer if you are getting errors.
*)
set pause to 0.7 -- adjust as needed
-- make as short as possible without errors
tell application "Papers.app"
activate
end tell
tell application "System Events"
tell process "Papers"
tell menu bar 1
tell menu bar item "File"
tell menu "File"
tell menu item "Export..."
tell menu "Export..."
click menu item "BibTeX Library"
end tell
end tell
end tell
end tell
end tell
end tell
keystroke "~/Desktop/from_papers.bib"
keystroke return
delay pause * 25
keystroke return
delay pause * 25 -- again: adjust as needed
end tell
do shell script "export PATH=/format/lib/path && formatlib ~/Desktop/from_papers.bib"
delay pause * 4
do shell script "rm ~/Desktop/from_papers.old.bib" --clean up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment