# Smart log while merging duplicated entries or better ways of citing two bibtex files?

**URL:** https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002
**Category:** Help
**Created:** [January 14, 2018, 11:52pm UTC](https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002 "2018-01-14T23:52:15Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![i2000s](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/i2000s/32/109_2.png) [@i2000s](https://discourse.jabref.org/u/i2000s)
#### Post date: [January 14, 2018, 11:52pm UTC](https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002/1 "2018-01-14T23:52:15Z")

</div>

I would like to merge two bibtex files which have a lot of overlaps and duplicated entries. Since these two bibtex database files are for different chapters of my dissertation, what is the best way of merging these database files? I have all chapter content finished, just need to make sure the References cited in the whole dissertation doesn’t duplicate in the end.

In my mind, I have the following workarounds/approaches:

1. Merge two files while always stick to the bibtex key of file A using JabRef. After merging, give me a log file on where bibtex keys were changed so that I can update my chapter citations accordingly. For this approach, I am sure if I can easily find this log file to track the changes in JabRef.

2. Use the two files separately for the two chapters or cite both bibtex files for all my dissertation content, so that I don’t need to change anything in the citations in my writing. At the end of the References section of my dissertation, all duplicated entries should be merged automatically–that is no duplicated info in the References section. Is this possible in general? I know this approach might not be related to JabRef functions, but I appreciate if anyone knows bibtex better than me to give a clue.

Thanks!

---

<div class="post-metadata">

### Author: ![mlep](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/mlep/32/387_2.png) [@mlep](https://discourse.jabref.org/u/mlep)
#### Post date: [January 15, 2018, 8:38am UTC](https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002/2 "2018-01-15T08:38:56Z")

</div>

For BibTeX, two entries with different keys are completely different entries (while their contents may be identical). So your 2nd approach would involve looking by yourself for the duplicated entries in the PDF file. The package showkeys may help you in identifying the entry keys.

My point of view: since you have many duplicates, I would go for the approach 1, i.e. merging the files and have a clean BibTeX file first. Then compile and look at the missing entries in the log file, and, finally, update the keys in the TeX files.

---

<div class="post-metadata">

### Author: ![Siedlerchr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/siedlerchr/32/216_2.png) [@Siedlerchr](https://discourse.jabref.org/u/Siedlerchr)
#### Post date: [January 18, 2018, 1:21pm UTC](https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002/3 "2018-01-18T13:21:25Z")

</div>

JabRef actually has a duplicate checker and entry merger in the tool menu or when you select two entries.  
It’s the same functionality to update the entry with information from e.g. doi.

So you could just simply import the second library in your first one and then go for the duplicate checker (checks a lot of fields, not just the key).

However, I would sugget keeping a backup in case sth goes wrong after merging.

---

<div class="post-metadata">

### Author: ![i2000s](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/i2000s/32/109_2.png) [@i2000s](https://discourse.jabref.org/u/i2000s)
#### Post date: [March 24, 2018, 6:37pm UTC](https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002/4 "2018-03-24T18:37:29Z")

</div>

I am thinking to write a bash or something script to automate this process:

1. Go through entries from bibtex file A to copy the bibtex info from the entry and look for if there is any duplicated item in bibtex file B.

2. If there is a duplication, then copy the bib-key for the entry in A as string c and search for tex file F to replace c with the bib-key d for the corresponding entry in B. If there is no duplication, then add the new entry into B and generate a new bib-key for the entry, then copy the bib-key for the entry in A as string c and search for the tex file F to replace c with the bib-key d for the corresponding entry in B.

3. Loop over all entries in A and finish all the replacement work for the tex file F.

For step 1 and 2, is there any way to use a script to ask JabRef to check duplication, add a new entry and spill out the correct strings for me? I feel this can serve many people’s needs, and can even be developed as a useful feature for JabRef 🙂

Thanks!

---

<div class="post-metadata">

### Author: ![sebastianst](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/sebastianst/32/581_2.png) [@sebastianst](https://discourse.jabref.org/u/sebastianst)
#### Post date: [July 6, 2019, 6:15pm UTC](https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002/5 "2019-07-06T18:15:30Z")

</div>

I think we are looking for the same solution:

> [@Save key mapping when merging or detecting duplicates](http://discourse.jabref.org/t/save-key-mapping-when-merging-or-detecting-duplicates/1682):
>
> When merging one bibliography into another, or detecting duplicates, it would be very useful to somehow save/export a mapping from the old entries’ keys to the target entry’s key. E.g. my main bib file contains an entry @article{authorFooBar2019,...} and the bib file I am merging into the main file contains @article{author\_foo\_bar\_baz\_2019,...} Jabref correctly detects the duplicate and I decide to merge them together into the main file’s entry, keeping the key authorFooBar2019. So far so g…

How did you eventually solve the issue

---

<div class="post-metadata">

### Author: ![Ifeanyi\_Ndukwe](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.jabref.org/ifeanyi_ndukwe/32/590_2.png) [@Ifeanyi\_Ndukwe](https://discourse.jabref.org/u/Ifeanyi_Ndukwe)
#### Post date: [August 15, 2019, 6:19am UTC](https://discourse.jabref.org/t/smart-log-while-merging-duplicated-entries-or-better-ways-of-citing-two-bibtex-files/1002/6 "2019-08-15T06:19:26Z")

</div>

Please, has anyone solved this issue? How was it solved?
