What's the best way to convert a Bibtex .bib file to an XML file that can be imported by MS Word 2010?
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")
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/
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
Using the R port of bibutils (rbibutils) I managed to do it much simpler in Windows.
https://geobosh.github.io/rbibutils/
Install with
install.packages("rbibutils")
Then it's just one easy command:
rbibutils::bibConvert("myfile.bib", "myfile.xml", informat = "bibtex", outformat = "word")
Rember to include the quotes, as this is R.
Based on Andreas Grivas script, I wrote and share you a multiple files bib to xml (word compatible) converter. You should run in inside the folder that contains your .bib files:
#this script convert a .bib file to xml file and to word xml file.
#this script use bibutils tools.
echo -e "===================\nscript to convert multiple .bib (bibtex) files to word xml\n==================="
echo -e "Settings\n==================="
mypwd=$(pwd)
output=$(pwd)/output
echo -e "Path:\n$mypwd"
echo -e "output folder:\n$output"
mkdir -p "${output}"
echo -e "===================\nProcessing"
counter=0
for file in *.bib;
do
counter=$((counter+1));
name=${file%.*};
echo -e "=================== \n$file"
bib2xml $name.bib | xml2wordbib | sed -e "$mypwd" -e "$mypwd" > "$output/$name.xml"
done
echo -e "==================="
echo -e "$counter .bib files were found.\nDone!"enter code here
The free reference manager software Mendeley also offers this option. You can open your .bib file and export to Endnote XML. You can download it at www.mendeley.com/download-desktop-new.
For those using Docker, https://github.com/derlin/docker-bib2word has a Dockerfile and a simple script to do the job.
To build the image:
git clone https://github.com/derlin/docker-bib2word
cd docker-bib2word
docker build -t bib2word --rm .
Then, just run:
docker run --rm -v $(pwd):/app bib2word biblio.tex
to convert biblio.tex
into biblio.xml
(the can be imported into word).
© 2022 - 2024 — McMap. All rights reserved.