Created
September 10, 2014 16:48
-
-
Save ihincks/9e5bb2ec0dd49a2c574b to your computer and use it in GitHub Desktop.
Call bibtex on all .aux files in directory with given base.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
''' | |
A call to this script | |
multi-bibtex [options] texfile[.aux] | |
will result in the commands | |
bibtex [options] file.aux | |
being called for every file in the folder of texfile which | |
starts with "texfile". | |
This is useful, for example, when you want to use bibtex | |
(as opposed to biber which does what we want automatically) | |
with the tex package biblatex's environment refsection, | |
which creates multiple .aux files, one for each refsection. | |
''' | |
import sys | |
import os | |
import subprocess | |
if __name__ == "__main__": | |
filename = sys.argv[-1] | |
args = sys.argv[1:-2] | |
suffix = '.aux' | |
bibtex = 'bibtex' | |
folder = os.path.dirname(os.path.abspath(filename)) | |
texfile = os.path.basename(filename) | |
if suffix in texfile: | |
texfile = texfile[:-4] | |
for f in os.listdir(folder): | |
if texfile in f and suffix in f: | |
cmd = [bibtex] + args + [f] | |
print ">>> Calling: {}".format(" ".join(cmd)) | |
subprocess.call(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment