如何将Bibtex .bib文件转换为可由MS Word 2010导入的XML文件?
Java应用程序JabRef是一个很棒的工具,我已经成功地使用它将我的BibTex条目导出为XML,并在Word 2013中无任何问题地导入了它们。
请访问:http://www.jabref.org/查看。
我找到了解决方案。
Bibutils在Ubuntu仓库中可用,提供了一些将BibTex转换为Word XML的工具,但是Word未能正确导入某些字段。以下是一些Python代码,可一次性完成所有操作。目前我已经为@article和@inproceedings条目做好了准备。
#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")
根据impala79s的答案,对于我来说,这个单行代码在使用MS Word 2007时有效。 mybib.bib是我们要转换为Word格式的输入bib文件,word.xml是我们想要将wordbib格式保存到的文件的输出名称。如上所述,您需要安装bibutils软件包。
bib2xml mybib.bib | xml2wordbib | sed -e 's/PeriodicalName/PeriodicalTitle/g' -e 's/>Proceedings/>ConferenceProceedings/g' > word.xml
PS. 你需要在机器上安装bibutils软件包,与上面的回答类似
基于Andreas Grivas的脚本,我编写并与您分享了一个多文件bib到xml(兼容word)转换器。您应该在包含.bib文件的文件夹中运行它:
#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
git clone https://github.com/derlin/docker-bib2word
cd docker-bib2word
docker build -t bib2word --rm .
然后,只需运行:
docker run --rm -v $(pwd):/app bib2word biblio.tex
将 biblio.tex
转换为 biblio.xml
(可导入到 Word 中)。