1 [[!template id=bzrrepo repo=pybtex]]
3 I keep my [[BibTeX]] databases neat and tidy with my own branch of
4 [Pybtex][]. The actual command used to re-format the files is
6 $ 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
8 Be sure to look over `pybtex.log` and `git diff path/to/db.bib` for
9 anything suspicious before committing the new file (you are versioning
10 it with [[Git]] right? ;). You may have to do some find-and-replacing
11 to handle changed keys and consolidate or rename automatically
14 You might also be interested in [bibtool][], but I'm more comfortable
15 tweaking things in [[Python]].
18 [Pybtex]: http://pybtex.sourceforge.net/
19 [bibtool]: http://www.ctan.org/tex-archive/biblio/bibtex/utils/bibtool/
23 [[!tag tags/programming]]