Skip to content

adamjgnoel/mendeleyBibFix

Repository files navigation

mendeleyBibFix

This is a simple function intended to correct bib-files that are automatically generated by Mendeley Desktop. I have found it to work for bib-files generated with the IEEE citation style, but it should work for other styles as well. It makes the following corrections:

  • changes double braces around titles to single braces
  • provides workaround for constraints on year via issn. If an entry has no year but has an ISSN, then the ISSN entry is renamed to year. This enables labeling a paper as "in press", "submitted", "to appear", or any other custom text for the end of the entry.
  • removes escaping of { and } (will only matter if you checked "Escape LaTeX special characters" in the "Bibtex" Options tab)
  • removes URL for any entry that is not specified as an exception (read the comment block after start of main function to read how to change the exceptions)
  • removes braces around months so that they appear correctly
  • removes all appearances of the "annote" field, which is used by Mendeley for personal annotations to the entry. Warning: Contents of this field will not be correctly removed if there is a newline character after a closing curly brace and comma (i.e., "},\n") within the text of the annotation, as this text is used to detect the end of the annotation in the bib-file.
  • removes all appearances of the "file" field, which lists the location of a local soft copy

It should work correctly for files generated by Mendeley Desktop v1.16.1. Still works as of v1.19.5.

A number of fixes are hard-coded, i.e., it expects to know where the braces are. So this code runs very fast (bib files with hundreds of entries are fixed in a small fraction of a second) but may not be "future-proof"

You will need to compile this code to run it. A compiled version for Windows is included on the release page of Github. If you are going to compile it yourself with gcc, then you will need the -std=c99 option (e.g., command like “gcc -o mendeleyBibFix mendeleyBibFix.c -std=c99”).

The full call syntax is as follows:

  • Call syntax (Windows): mendeleyBibFix.exe [OUTPUT_FILENAME] [INPUT_FILENAME]
  • Call syntax (Linux or macOS): ./mendeleyBibFix [OUTPUT_FILENAME] [INPUT_FILENAME]

Both arguments are optional. If there is only one argument, then it is assumed to be the output filename. The default input filename is "library.bib" (which is the default name of the bib-file that Mendeley generates), and the default output filename is "library_fixed.bib".

You can run the script in one of two ways:

  1. Open a command window and navigate to the folder containing both the bib-file and the executable (e.g., cd "C:\Users\Documents..."). Then enter (for Windows) "mendeleyBibFix.exe OUTPUT_FILENAME INPUT_FILENAME". You can omit the filename arguments if your bib-file is called library.bib and you want the script to create library_fixed.bib.
  2. If you're happy with the default arguments, and if the executable is placed in the same directory as the bib-file "library.bib", then you can just double-click on the executable