Skip to content

Commit 75f37ce

Browse files
committed
Added removal of "file" field
1 parent 2ac196b commit 75f37ce

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library.bib
2+
library_fixed.bib
3+
*.exe

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ This is a simple function intended to correct bib-files that are automatically g
77
* 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)
88
* removes braces around months so that they appear correctly
99
* removes all appearances of the "annote" field, which is used by Mendeley for personal annotations to the entry
10+
* removes all appearances of the "file" field, which lists the location of a local soft copy
1011

11-
It should work correctly for files generated by Mendeley Desktop v1.16.1.
12+
It should work correctly for files generated by Mendeley Desktop v1.16.1. Still works as of v1.17.8.
1213

1314
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"
1415

mendeleyBibFix.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* mendeleyBibFix - correct formatting of bib-files that are automatically
33
* generated by Mendeley Desktop
44
*
5-
* NOTE: Mendeley Desktop is copyright 2009-2013 by Mendeley Ltd.
5+
* NOTE: Mendeley Desktop is copyright 2008-2016 by Mendeley Ltd.
66
* This software is not provided by Mendeley and the author has no affiliation
77
* with their company.
88
*
@@ -20,6 +20,7 @@
2020
* - removes braces around months
2121
*
2222
* It should work correctly for files generated by Mendeley Desktop v1.16.1.
23+
* Still functioning as of v1.17.8.
2324
*
2425
* A number of fixes are hard-coded, i.e., it expects to know where the braces are.
2526
* So this code runs very fast (bib files with hundreds of entries are fixed in a
@@ -41,10 +42,13 @@
4142
* Distributed under the New BSD license. See LICENSE.txt for license details.
4243
*
4344
* Created June 15, 2016
44-
* Current version v1.1 (2016-10-26)
45+
* Current version v1.2 (2017-03-17)
4546
*
4647
* Revision history:
4748
*
49+
* Revision v1.2 (2017-03-17)
50+
* - added removal of "file" field, which lists location of local soft copy
51+
*
4852
* Revision v1.1 (2016-10-26)
4953
* - added removal of "annote" field, which includes personal annotations
5054
*
@@ -300,7 +304,14 @@ int main(int argc, char *argv[])
300304
memmove(&curBibEntry[curBibInd+1], &curBibEntry[indEOL+1],
301305
curBibLength - indEOL + 1);
302306
curBibLength -= indEOL - curBibInd;
303-
curBibInd--; // Correct index so that line after URL is read correctly
307+
curBibInd--; // Correct index so that line after annote is read correctly
308+
} else if(!strncmp(&curBibEntry[curBibInd+1], "file =",6))
309+
{ // Entry has a filename. Erase the whole field
310+
indEOL = findEndOfField(curBibEntry, curBibInd+1);
311+
memmove(&curBibEntry[curBibInd+1], &curBibEntry[indEOL+1],
312+
curBibLength - indEOL + 1);
313+
curBibLength -= indEOL - curBibInd;
314+
curBibInd--; // Correct index so that line after filename is read correctly
304315
}else if(!bUrlException
305316
&& !strncmp(&curBibEntry[curBibInd+1], "url =",5))
306317
{ // Entry has a URL but it should be removed. Erase the whole line

0 commit comments

Comments
 (0)