Advertisement
Guest User

import with pdfMeat

a guest
Jan 25th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tell application "BibDesk"
  2.     set theDoc to document 1
  3.     tell theDoc
  4.         set theSel to selection
  5.         set thePub to item 1 of theSel
  6.         tell thePub
  7.             -- current (probably empty?) BibTeX record
  8.             set curBibTeXRecord to get BibTeX string of thePub
  9.            
  10.             -- get the BibTeX record using pdfmeat.py. Wrap it in a shell script because it needs a full path, write access to a folder, etc.
  11.             set theFile to get linked files
  12.             set thePath to POSIX path of theFile
  13.             set shellOpts to "cd /tmp; PATH=$PATH:/usr/local/bin "
  14.             set pdfMeatCmd to "/Users/mankoff/bin/python /Users/mankoff/bin/pdfmeat.py "
  15.             set shellCmd to shellOpts & pdfMeatCmd & "'" & thePath & "'"
  16.             --set pdfMeatOutput to do shell script shellCmd
  17.             -- For debugging, don't query Google Scholar
  18.             set pdfMeatOutput to "@article{McCracken:2005, Author = {M. McCracken and A. Maxwell}, Title = {Working with BibDesk.},Year={2005}}"
  19.             display dialog pdfMeatOutput
  20.            
  21.         end tell
  22.        
  23.         set newPub to import from pdfMeatOutput
  24.        
  25.         tell newPub
  26.             make new linked file with data theFile at beginning of linked files
  27.         end tell
  28.        
  29.         --delete thePub
  30.        
  31.     end tell
  32. end tell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement