Skip to content

Commit

Permalink
Added removal of "file" field
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjgnoel committed Mar 17, 2017
1 parent 2ac196b commit 75f37ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library.bib
library_fixed.bib
*.exe
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ This is a simple function intended to correct bib-files that are automatically g
* 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
* 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.
It should work correctly for files generated by Mendeley Desktop v1.16.1. Still works as of v1.17.8.

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"

Expand Down
17 changes: 14 additions & 3 deletions mendeleyBibFix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* mendeleyBibFix - correct formatting of bib-files that are automatically
* generated by Mendeley Desktop
*
* NOTE: Mendeley Desktop is copyright 2009-2013 by Mendeley Ltd.
* NOTE: Mendeley Desktop is copyright 2008-2016 by Mendeley Ltd.
* This software is not provided by Mendeley and the author has no affiliation
* with their company.
*
Expand All @@ -20,6 +20,7 @@
* - removes braces around months
*
* It should work correctly for files generated by Mendeley Desktop v1.16.1.
* Still functioning as of v1.17.8.
*
* 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
Expand All @@ -41,10 +42,13 @@
* Distributed under the New BSD license. See LICENSE.txt for license details.
*
* Created June 15, 2016
* Current version v1.1 (2016-10-26)
* Current version v1.2 (2017-03-17)
*
* Revision history:
*
* Revision v1.2 (2017-03-17)
* - added removal of "file" field, which lists location of local soft copy
*
* Revision v1.1 (2016-10-26)
* - added removal of "annote" field, which includes personal annotations
*
Expand Down Expand Up @@ -300,7 +304,14 @@ int main(int argc, char *argv[])
memmove(&curBibEntry[curBibInd+1], &curBibEntry[indEOL+1],
curBibLength - indEOL + 1);
curBibLength -= indEOL - curBibInd;
curBibInd--; // Correct index so that line after URL is read correctly
curBibInd--; // Correct index so that line after annote is read correctly
} else if(!strncmp(&curBibEntry[curBibInd+1], "file =",6))
{ // Entry has a filename. Erase the whole field
indEOL = findEndOfField(curBibEntry, curBibInd+1);
memmove(&curBibEntry[curBibInd+1], &curBibEntry[indEOL+1],
curBibLength - indEOL + 1);
curBibLength -= indEOL - curBibInd;
curBibInd--; // Correct index so that line after filename is read correctly
}else if(!bUrlException
&& !strncmp(&curBibEntry[curBibInd+1], "url =",5))
{ // Entry has a URL but it should be removed. Erase the whole line
Expand Down

0 comments on commit 75f37ce

Please sign in to comment.