1

I found there are hundreds of cases of duplicated citation keys in one of my bib file. It seems generated by Mendeley but I'd rather believe it was me who made such mistake (I didnt remember I ever copied another bib file into this one, though). Anyway, now my problem is how to assign different citation keys to the enties sharing the same key (they are different articles). Doing this manually would be a bit time-consuming though could be fun if I try to make it ;). Is there some way by which this job can be done in one stroke? or I need to compose a Python script for this task?

moewe
  • 175,683
farhill
  • 63
  • JabRef has the functionality to cycle through duplicates (from reading the documentation). – Werner Oct 20 '20 at 23:11
  • 2
    Effectively, JabRef can make unique keys for all the database with just one click. The problem is only if you also have some text citing these references, that in some cases will point to the wrong key an in others to the lost key, and there are no programs to solve this. – Fran Oct 21 '20 at 05:45
  • 2
    https://tex.stackexchange.com/q/76420/35864, https://tex.stackexchange.com/q/484975/35864, https://tex.stackexchange.com/q/431614/35864 may be of interest. – moewe Oct 21 '20 at 06:08
  • Finding duplicate cite keys should be fairly straightforward, but then you still need to decide if the two entries are the same or different (I wouldn't want to assume that they are always different). In a second step you may also want a feature to find duplicate entries. That is much harder. I've heard that JabRef does very good things at that front as well, but I'd expect it's possible that automated solutions simply don't catch everything. In the end you may also need to worry about changed entry keys if you have old documents that you want to use with your new .bib file. – moewe Oct 21 '20 at 06:22
  • 1
    Does this answer your question? Cleaning up a .bib file – Elad Den Oct 21 '20 at 07:11
  • What I need is to automatically modify the duplicated citation keys in my bib file. When I search in JabRef using the duplicated key, several documents sharing the same key will show. Then I click Generate Citation Key, the documents' key will be automatically modified except the first one. The problem w/ this approach is that I still need to manually input every key... I tried Select All and click Generate citation keys hoping it can detect all duplicated keys and regenerte them but it did not work. – farhill Oct 21 '20 at 08:23
  • Seems to me JabRef's Generate Citation Key can only handle a group of documents left in the window sharing same keys. If there are two different keys each has its own group of documents, then this feature fails to work. Is that so? – farhill Oct 21 '20 at 08:23
  • Thanks for the other solutions provided but they seem all handle the duplicated reference entries in one article which is not what I need here. – farhill Oct 21 '20 at 08:24
  • " I still need to manually input every key" Nope. Do not search anything. Just select all the references (click on the first, and with Shift pressed, click on the last), the click on the bottom with a key symbol, confirm that you want to overwrite the existing keys, and that is all. Use the menu of "search for duplicates" to avoid changes in another keys (because they do not follow the default Surname+Year pattern) that should not be changed because are already cited in text. Or to detect and remove real superfluous duplicates. Otherwise, let JabRef rename all the keys. – Fran Oct 22 '20 at 08:14

1 Answers1

0

Found the solution. You need to install the BBT plug-in on Zotero first. Then, a. Import the bib file into Zotero. b. Select all. Right click and select Better Bib TeX – Pin Bib TeX key. The BBT will automatically regenerate ALL citation keys - the previous ones will all be discarded. c. Export to a new bib file. The regenerated keys are pretty long, for example, "accessDrivingSaferGreenera". But it is ok for me. At least I dont need to set the duplicated keys one by one...

farhill
  • 63
  • Import, export and odd bibkeys. All of this is can be avoided with JabRef, and as I explaned above, Jabref can make all the keys at once, not one by one, and moverover, you can specify the desired pattern for the auto generation of the bibkeys. You should take a closer look to this program. – Fran Oct 22 '20 at 08:34
  • Agree with @Fran this is the best bibliography management software that is free and plays well with Latex Lyx and family. The only caveat its java so some enterprise systems do not allow installation of this. It also has ability to search and add from Medline/Pubmed/DOI. – Vivek Sharma Nov 15 '21 at 19:14