[[!template id=bzrrepo repo=pybtex]] I keep my [[BibTeX]] databases neat and tidy with my own branch of [Pybtex][]. The actual command used to re-format the files is $ python -c 'from pybtex.database.input.bibtex import Parser; from pybtex.database.output.clean_bibtex import Writer; p = Parser(); d = p.parse_file("path/to/db.bib"); w = Writer(); w.write_file(d, "path/to/db.bib", p.get_raw_macros())' 2> pybtex.log Be sure to look over `pybtex.log` and `git diff path/to/db.bib` for anything suspicious before committing the new file (you are versioning it with [[Git]] right? ;). You may have to do some find-and-replacing to handle changed keys and consolidate or rename automatically generated macros. You might also be interested in [bibtool][], but I'm more comfortable tweaking things in [[Python]]. [Pybtex]: http://pybtex.sourceforge.net/ [bibtool]: http://www.ctan.org/tex-archive/biblio/bibtex/utils/bibtool/ [[!tag tags/latex]] [[!tag tags/programming]] [[!tag tags/python]] [[!tag tags/tools]]