简体   繁体   中英

Compile a whole Folder with tex files using python

how to compile a folder which content of latex files. I would try to use python to compile the whole folder.

In the past I use the Terminal to compile the folders

for i in *.tex; do pdflatex $i;done

but I rather use Python

I don't know of any good pdflatex bindings in python, but you could just use subprocess.

import subprocess
import glob

for path in glob.iglob('*.tex'):
    subprocess.run(['pdflatex', path])

If you want to be able to use this from the command line and pass any directory path to it, you can do something like for path in glob.iglob(os.path.join(sys.argv[1], '*.tex')): instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM