How do I convert a BibTex bib file to Word 2010 XML?

Here's the solution I found.

Bibutils, available in the Ubuntu repos, provides some tools for converting BibTex to Word XML, but there was some trouble with Word not importing some of the fields properly. Here's some Python Code to do it all in one go. So far i've got it going for @article and @inproceedings entries..

#THIS REQUIRES THAT bibutils IS INSTALLED ON YOUR MACHINE

"""
Usage:
./Bib2Word2010XML.py [Input file name] [Output file name]
"""

import sys
import fileinput
import os

if __name__ == '__main__':
  #input a BibTex .bib file
  fnameIN = sys.argv[1]
  fnameOUT = sys.argv[2]

  #run bibutils functions to convert to Word XML
  os.system("bib2xml " + fnameIN + " > TEMPOUT1.xml")
  os.system("xml2wordbib TEMPOUT1.xml > TEMPOUT2.xml")
  os.system("rm TEMPOUT1.xml")

  #clean up for Word 2010 formatting
  f1 = open('TEMPOUT2.xml', 'r')
  f2 = open(fnameOUT, 'w')
  for line in f1:
    line = line.replace("ArticleInAPeriodical", "JournalArticle")
    line = line.replace("PeriodicalName", "JournalName")
    line = line.replace("Proceedings", "ConferenceProceedings")
    f2.write(line)
  f1.close()
  f2.close()
  os.system("rm TEMPOUT2.xml")

Based on impala79s' answer this one-liner worked for me using MS Word 2007. mybib.bib is the input bib file we want to convert to word format and word.xml is the output name of the file we want to save the wordbib format to. As stated above you need to install the bibutils package.

bib2xml mybib.bib | xml2wordbib | sed -e 's/PeriodicalName/PeriodicalTitle/g' -e 's/>Proceedings/>ConferenceProceedings/g' > word.xml

PS. You need bibutils package installed on your machine similarly with above answer


The Java application JabRef is a great tool, I have used it successfully to export my BibTex entries to XML and imported them into Word 2013 with no problems at all.

Check it out at: http://www.jabref.org/

Tags:

Ms Word

Bibtex