[Feature Request] Applescript to Export Groups as Formatted References

A place for users to ask each other questions, make suggestions, and discuss Bookends.
Post Reply
iandol
Posts: 481
Joined: Fri Jan 25, 2008 2:31 pm

[Feature Request] Applescript to Export Groups as Formatted References

Post by iandol »

Currently we can format individual references using Applescript:

Code: Select all

set bibtexRefs to format myPubs using "BibTeX.fmt" as BibTeX
The problem is when you want to export many references this becomes really really slow, requiring special tricks of batching up references into smaller groups to not cause Applescript to freeze which still is really slow:

https://github.com/iandol/bookends-tool ... pplescript

For example, exporting my main reference set of ~7100 references takes >31 minutes using Applescript and ~1.5 minutes when using Bookends export. There is also a leak of memory when using Applescript (Jon has said it is Apple's code that leaks) that causes VM memory of WindowManger to shoot up (it drops back down when Bookends is closed), and more CPU use for the whole period it runs.

It would be nice therefore if we could automate the Export References feature of the File menu to export whole groups rather than individual references. This would trigger the same fast and efficient mechanism that Bookends runs already:

Code: Select all

export myGroup to myFile using "BibTeX.fmt" as utf8 
Currently Bookends only allows Hits to selected be exported in the GUI, but I assume it is fairly easy to allow the Applescript selection to treat named groups in the same way, as Bookend's Applescript dictionary already has the concept of "group items". This would make it much easier for those of us who use Bookends as part of a bigger workflow that depends on an accessible reference library to operate (LaTeX, Pandoc or many other tools).
Jon
Site Admin
Posts: 10291
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: [Feature Request] Applescript to Export Groups as Formatted References

Post by Jon »

I assume you've tried something like this (from the user guide)?

tell application "Bookends"
set groupName to "My Papers" -- adopt to your needs
set outFile to ((path to desktop from user domain) as string) & "Bibliography.ris"
tell front library window
set pubsList to publication items of group item groupName
if pubsList is not {} then
set risContent to format pubsList using "RIS.fmt"
my writeTextToFile(outFile, risContent)
end if
end tell
end tell

Jon
Sonny Software
iandol
Posts: 481
Joined: Fri Jan 25, 2008 2:31 pm

Re: [Feature Request] Applescript to Export Groups as Formatted References

Post by iandol »

Yes, if I run that code Bookends consumes >4GB of my 8GB of RAM before causing my whole system to crash :shock: . Screenshot taken a minute or so before the system froze (while memory was still growing):
Screen Shot 2020-12-15 at 07.50.01.png
Screen Shot 2020-12-15 at 07.50.01.png (59.59 KiB) Viewed 2125 times
For smaller groups (I think up to around 1000 refs) it is OK, but for larger databases this will crash the OS (perhaps if you have more system memory it can manage larger exports). This is why we ended up having to use the batch method (see the applescript in my original post), which breaks up the reference list into smaller batches and loops over each writing out to the file for each batch, this is inevitably slower but can process large databases...

Having retested all this on Big Sur, one piece of good news is that the new applescript events seems as fast as the older deprecated appleevents system (appendix C of the maual), this wasn't the case the last time I checked where the old events were around 1.8X faster than the new much nicer interface.
Post Reply