diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dc389f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +library.bib +library_fixed.bib +*.exe \ No newline at end of file diff --git a/README.md b/README.md index 72ecc34..a214b73 100644 --- a/README.md +++ b/README.md @@ -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" diff --git a/mendeleyBibFix.c b/mendeleyBibFix.c index 6ba2708..4af10bc 100644 --- a/mendeleyBibFix.c +++ b/mendeleyBibFix.c @@ -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. * @@ -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 @@ -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 * @@ -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