Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Command line 如何在Windows 7上的多个.tex文件上运行pdflatex.exe?_Command Line_Pdflatex - Fatal编程技术网

Command line 如何在Windows 7上的多个.tex文件上运行pdflatex.exe?

Command line 如何在Windows 7上的多个.tex文件上运行pdflatex.exe?,command-line,pdflatex,Command Line,Pdflatex,例如,我想在所有.tex文件上运行pdflatex.exe,这些文件的名称以Chap03\ux开头。我该怎么做 注: 所有的.tex文件总是在同一个特定的文件夹中,所以我认为这是可以利用的 因为是同一个文件夹,所以使用名称的开头很重要 在某些情况下,我还希望在上述文件上使用lualatex.exe 一次只能有一个进程,然后是下一个进程,这一点非常重要。也许这有点奇怪,但我只是没有这方面的任何经验 这些文件都是UTF-8编码的 我想这会导致一个批处理脚本?我的意思是,只要双击某个东西,然后让魔法发

例如,我想在所有.tex文件上运行pdflatex.exe,这些文件的名称以Chap03\ux开头。我该怎么做

注:

所有的.tex文件总是在同一个特定的文件夹中,所以我认为这是可以利用的

因为是同一个文件夹,所以使用名称的开头很重要

在某些情况下,我还希望在上述文件上使用lualatex.exe

一次只能有一个进程,然后是下一个进程,这一点非常重要。也许这有点奇怪,但我只是没有这方面的任何经验

这些文件都是UTF-8编码的


我想这会导致一个批处理脚本?我的意思是,只要双击某个东西,然后让魔法发生,这就太棒了

您可以通过多种编程语言通过很少几行代码来解决这个问题。接下来的步骤是列出目录中的所有文件,将该列表中的所有文件从Chap03_u开始,以.tex结束。然后对每个文件调用pdflatex。例如,这是在以下Python 2.7脚本中完成的:

import os

method = raw_input('Which method do you desire pdflatex/lualatex/xelatex?')
files = os.listdir(os.getcwd())

def fun(i):
    """If i begins with Chap03_ and ends with .tex i is returned else 
    None is retruned"""
    loc1 = i.find('Chap03_')
    loc2 = i.find('.tex')
    if loc1 == 0 and (len(i)-len('.tex')) == loc2:
        return(i)

texFiles = [fun(i) for i in files if fun(i) is not None]
for i in texFiles:
    os.system(method + ' ' +i)

脚本将在其所在的文件夹中搜索,或在其parrent程序调用的位置搜索。换句话说,只需将其放在相关文件夹中,并在需要编译所有PDF时单击它即可。命令提示符将询问使用pdflatex/lualatex/xelatex的方法。如果您没有使用Python,我建议您安装Anaconda2 Python 2.7,安装后您将能够运行此脚本。

您是否尝试从命令行使用pdflatex.exe Chap03*?“这通常会管用的。”谢尔特试过了。不起作用/