Tag Archives: tutorial

Merging Mendeley and Zotero bib files (Windows)

UPDATE: @mrgunn informed me of a native function in Mendeley to merge the libraries, making the steps below redundant. The setup is trivial: in Mendely, go to Tools–>Options–>Zotero/CiteUlike tab. Open the SQL database from Zotero and it will automatically import the data (including attached PDFs). If you do not know where to find your Zotero library, go to (within Zotero standalone) to Tools–>Options–>Advanced–>Files and Folders–>Show data directory.

The original post can be found below.

##############################################################################

I recently started using Zotero next to Mendeley for my reference management, but I was sort of agitated about maintaining two libraries in two different programs. I like Zotero’s quicksave too much and Mendeley’s auto import too much to give up either one, so I decided to figure out how to make it easy for me to cite from both libraries when writing up papers in LaTeX. Below I will outline how to make one full library file on a semi-automatic basis (i.e. requires only one key press to update your library).

Step 1—Set Mendeley and Zotero to automatically sync your references into a BibTeX file
Mendeley has a default option to sync the library into a BibTeX file. This option can be found under the menu option Tools–>Options–>BibTeX. I recommend syncing your entire library into one file and not per collection, otherwise you will have to update the script (explained in step 2) everytime you create a new collection.
For Zotero, an add-on needs to be installed, which can be found here. This is a Zotero to BibTeX plugin developed by Robin Wilson. Installing it is easy (just follow the steps on his website) and it will allow you to sync your Zotero library into the folder of your choosing. I recommend syncing it into the same folder as the Mendeley file.

Step 2—Make a script for merging the .bib files
This step sounds much more difficult than it is. We need only two lines of code to make the script run. The first line changes the working directory (you will need to fit this to the folder you sync the Mendeley- and Zotero .bib files to) and the second creates the merged .bib file. All you need to do is open notepad and type in:

cd C:UsersChris HartgerinkDropboxBibs
copy library.bib+Zotero.bib fulllib.bib

Note that you will have to check whether the path file and file names correspond to your personal settings. You subsequently save this file as merge.bat (or any other filename, but with extension .bat), and run it to merge your libraries.

Step 3—Use AutoHotKey to create a keyboard shortcut for running the script
This step is optional, but highly recommended. AutoHotKey is a program where you can write map keyboard shortcuts to virtually any action you want. Installing AutoHotKey is a breeze, and the only thing you need to do is create a .ahk file that contains your key mappings. I personally keep one file where I maintain ‘all’ the code (use only 30 lines) and automatically run this at startup (see here for a how-to). I mapped the script to the control + F7 key, resulting in the ‘code':

!F7::Run,merge.bat,C:UsersChrisDropboxBibs

The ! stands for the control key (^ stands for alt, see here for an introductory tutorial). Everytime I use this keyboard shortcut the merge script runs and updates my library BibTeX file.

My apologies for the Mac and Linux users who I leave in the dark with this tutorial.

 

Share