I've recently moved to using Mendeley as my main reference management tool. It has some pretty neat features except for a few that keep bugging me. One of those is that Mendeley seems to maintain record of deleted entries in its database and those end up in its BibTeX export. Worst of all is that I am always getting duplicate entries in the BibTeX file.
Today I found a neat solution based on the post by
Simon Greenhill. Here's how it works for the citation key:
- Locate your Mendeley SQLite Library (~/Library/Application Support/Mendeley Desktop/youremail@www.mendeley.com.sqlite)
- from your terminal type:
sqlite3 your-email-address\@www.mendeley.com.sqlite - Type:
SELECT COUNT(*) as entries, citationkey FROM Documents GROUP BY citationkey HAVING entries > 1;
This basically queries the table "Documents" for all duplicate citation keys. - Then,
DELETE FROM Documents WHERE id NOT IN (SELECT MAX(id) FROM Documents GROUP BY citationkey);
Voila!