I have a LaTeX project (a research paper) that uses .bib file (old.bib). I received a new .bib file (new.bib), which includes the BibTeX entries present in old.bib with more complete information, but sometimes using a different entry name.
How can I merge new.bib with old.bib so that new.bib uses entry names from old.bib, for the entries present in both new.bib and old.bib? Note that I don't want to add any entries in new.bib, but only change entry names for entries also present in old.bib.
Example (in practice I'll have much longer .bib files):
Input:
new.bib:
@inproceedings{lesterpaper,
title={The Power of Scale for Parameter-Efficient Prompt Tuning},
author={Lester, Brian and Al-Rfou, Rami and Constant, Noah},
booktitle={Empirical Methods in Natural Language Processing},
pages={3045--3059},
publisher = {Association for Computational Linguistics},
year={2021}
}
@article{bommasani2023holistic,
title={Holistic Evaluation of Language Models},
author={Bommasani, Rishi and Liang, Percy and Lee, Tony},
journal={Annals of the New York Academy of Sciences},
year={2023},
publisher={Wiley Online Library}
}
old.bib:
@inproceedings{lester,
title={The Power of Scale for Parameter-Efficient Prompt Tuning},
author={Lester, Brian and Al-Rfou, Rami and Constant, Noah},
booktitle={EMNLP},
publisher = {Association for Computational Linguistics},
year={2021}
}
@inproceedings{tokpo2022text,
title={Text Style Transfer for Bias Mitigation using Masked Language Modeling},
author={Tokpo, Ewoenam Kwaku and Calders, Toon},
booktitle={NAACL: HLT-SRW},
pages={163--171},
publisher = {Association for Computational Linguistics},
year={2022}
}
Output new new.bib:
@inproceedings{lester,
title={The Power of Scale for Parameter-Efficient Prompt Tuning},
author={Lester, Brian and Al-Rfou, Rami and Constant, Noah},
booktitle={Empirical Methods in Natural Language Processing},
pages={3045--3059},
publisher = {Association for Computational Linguistics},
year={2021}
}
@article{bommasani2023holistic,
title={Holistic Evaluation of Language Models},
author={Bommasani, Rishi and Liang, Percy and Lee, Tony},
journal={Annals of the New York Academy of Sciences},
year={2023},
publisher={Wiley Online Library}
}
The only change in that new new.bib in the example is that the Bibtex entry name lesterpaper was changed to lester.
lesterandlesterpaperare not the same entry asbooktitlediffers. What is to distinguish a case where the same authors have published under the same title in two different books issued by the same publisher in the same year versus a case where you've entered different titles for the same book in different places? If you had a unique identifier, I could see how it might work - at least in principle - but that would need something like ISBN for books. – cfr Mar 28 '24 at 03:31biberin tool mode? Not sure if you could do it just withbiberor if you'd need something else. Thinking about it, if your bib files are reasonably consistently formatted, you could probably just useawk. You could even justcutold.bibandnew.bibinto pieces, pulltitlefrom each piece ofnew,grepoldand get the key if there's a match. Then just sed/awk to replace the key. Of course, it probably wouldn't work on Windows, but it seems doable anywhere else. – cfr Mar 28 '24 at 04:19bibmanagers, but I've not looked at any for years. – cfr Mar 28 '24 at 19:29