python - 批处理文件: Run command for every file of certain extension

标签 python batch-file

我运行 python 命令

python file.py inputfile.STL

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

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

请注意,.STL 文件将具有不同的前缀。

最佳答案

这些主题可以提供帮助: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 的所有文件。

关于python - 批处理文件: Run command for every file of certain extension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19951271/

相关文章:

python - 在 matplotlib 中一起分解多个饼图

batch-file - 在 z/OS 上运行部署在 Liberty 配置文件中的 Java 批处理

orm - 如何使用 dapper orm 执行批处理操作?

windows - 新 WebBinding : Cannot retrieve the dynamic parameters for the cmdlet

python - 如何将Openpyxl生成的xlsx输出到浏览器?

python - 为什么 Sympy 会切断系数较小的多项式项?

windows - 从 DOS/Windows 批处理文件运行 Sybase SQL 命令

sql-server - 在 Windows 批处理文件中将日期附加到文件名

python - 如何更改 JSON 文件中的嵌套值?

python - 在仅包含 1 和 0 的数组中找到第一个 1 的索引,所有 0 都在数组的左侧,所有 1 都在右侧?