On Jan 25, 2011, at 17:02, enas wrote:

> Dear list members,
> 
> I'm trying to implement a simple TextMate command that will open the PDF of a 
> paper that's being cited (and maybe another one that will just show me its 
> title). I'm pretty fluent in TextMate related stuff, but I will need to 
> include some AppleScript in the middle, in which I'm not fluent by any means. 
> Now I understand this is very basic, and I could probably figure out 
> everything I need in half a day, but I cannot afford that at the moment 
> unfortunately.
> 
> So I'd like to have a simple AppleScript that will receive the path to a bib 
> file, a cite key, and return me the path to the first PDF in the linked files 
> of the corresponding publication. Any hint on doing that?
> 

tell application "BibDesk"
  open POSIX file "/path/to/bibtex/file.bib"
  tell front document
    set thePubs to publications whose cite key is "citekey"
    if (count of thePubs) > 0 then
      set thePub to contents of item 1 of thePubs
      tell thePub
      if (count of linked files) > 0 then
        return POSIX path of linked file 1
      end if
      end tell
    end if
  end tell
end tell

(typed in Mail).

> Or is there a way I can access the information that is encoded in the bib 
> file without using AppleScript?
> 
> Thanks,
> 
> enas

You could use Spotlight, which you can access from the command line (or a 
script) using mdfind and mdls. 

mdfind "net_sourceforge_bibdesk_citekey == '<key>'"

returns the path to a .bdskcache file that contains the attributes for the item 
with cite key <key> (if it exists), while 

mdls -raw -name kMDItemWhereFroms "/path/to/file.bdskcache"

will return the linked files and URLs for the item.

Christiaan


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to