I explained in another post why I decided to switch my bibliography (back) from Zotero to BibLatex. Here I give some (minimal) hints about the process, in case it might help others going the same path.

Objectives

My Zotero library has around 2000 items. Many items have one or several notes attached to them. Many also have file attachments, in various formats (primary being PDF). The goal is to:

• Export the database to BibLaTex format.
• For each item, create an entry in a Reading_notes.org file. Under that heading, store the notes of each item.
• Get all the file attachments from Zotero's arborescence into a single folder. The file attachments should be renamed according to the key of the bibtex item.
• I sometimes use org-noter to take notes when I read a PDF. The .org file where the notes are stored should have the correct property drawers to relate to the PDF file.
Getting a .bib file out of Zotero

Zotero's Bibtex export is notoriously broken. To the extent that there is a plugin called "Better BibTex" whose main purpose is to fix the bugs in Zotero (thanks to retorquere alias Emiliano Heyns!). Why there should be a plugin for that, instead of just improving Zotero's handling of BibTex, is beyond my understanding. Anyway, Better Bibtex did a good job at exporting the Zotero database to a semantically correct BibLatex file.

There was one glitch however: I use blockquotes in my Zotero notes, and these were not exported to latex markup. I had to add a "case" for that to "switch (tag.nodeName)" in "resource/Better Biblatex.js":

case 'blockquote': latex = '\n\n\\begin{quotation}\n...\n\n\\end{quotation}\n'; break;

EDIT [2020-09-24]: The fix was merged into Better Bibtex.

Cleaning the .bib file in Emacs

In Emacs, I first used ebib (from Joost Kremers) to check the database and tidy up a few things.

Some of those things were repetitive so I wrote a set of functions to handle them. These functions  only leverage really those which ebib already provides.

They are in vic-import-from-zotero-to-ebib.el  on my emacs-config Framagit. If you want to use them, make sure that you also get vic-bib-functions.el whose purpose is more general.

Basic usage (see the docstrings of each function for details):

• vic/ebib-convert-groups-to-keywords' :: Better Bibtex uses the Groups field in the bibtex export to indicate that an entry belongs to one or several collections. Use this function to move the contents of the Groups field to the Keywords field adding to the existing keywords
• vic/ebib-fix-zotero-keywords' :: strip from keywords those characters not suited for org tags. Add space after comma separator because that's ebib's default.
• vic/ebib-import-zotero-file' :: bring zotero attachments of the entry at point into the default attachment folder. Uses Prince from https://www.princexml.com/ to convert html attachments to pdf (you need to install Prince to use this)
• vic/ebib-annotation-to-org' :: convert the latex annotation field of the entry at point to a note in org-mode format.

These functions operate on the entry at point in the ebib index window.

It's easy to bind one of this functions to an easily accessed key. Ex:

(define-key ebib-index-mode-map (kbd "C-$") 'vic/ebib-import-zotero-file) Then use ebib to filter the database down to entries which need to be edited with that function. For instance, those which have • a non-empty groups field • the base zotero path in their file field • a non-empty annotation field Apply the function, check the results, move on to the next entry. Optionally, record a macro to just apply-move with one key. (define-key ebib-index-mode-map (kbd "C-$") 'vic/ebib-annotation-to-note)

Writing these functions was fun and a good way to learn some elisp too. Use at your own risk. Hint: risk is considerably mitigated if you track your changes using git (→ one of the great benefits of using plain text formats!).