【问题标题】:Batch file: Run command for every file of certain extension批处理文件:为特定扩展名的每个文件运行命令
【发布时间】:2013-11-13 10:25:45
【问题描述】:

我运行一个 python 命令

python file.py inputfile.stl

但我想将其扩展为一次输入多个文件。我将如何制作一个 Windows 批处理文件,该文件在运行时将为该目录中的每个 *.stl 文件运行一个命令。例如它会运行,

python file.py INPUTFILE1.stl
python file.py ANOTHERFILE.stl
python file.py BLAH.stl
....

请注意,.stl 文件会有不同的前缀。

【问题讨论】:

    标签: python batch-file stl dos


    【解决方案1】:

    这些主题可以提供帮助:Batch script loopbatch file Copy files with certain extensions from multiple directories into one directory

    所以基本上:

    for %f in (*.stl) do python file.py %f
    

    这将创建一个循环,执行目录中所有扩展名为 .stl 的文件。

    【讨论】:

    • 不完全是,.stl 文件的名称不同(前缀)。所以其中一个可以称为 abc.stl 而另一个可以称为 testing.stl
    • 啊,好吧,问题刚刚改变了:)。我看的时候还是INPUTFILE1.stl, INPUTFILE2.stl, ...
    猜你喜欢
    • 1970-01-01
    • 2016-08-10
    • 1970-01-01
    • 2018-09-21
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 2017-07-21
    • 2011-03-14
    相关资源
    最近更新 更多