我需要逐行读取 .txt 文件的每一行,将每一行作为参数传递给我在 CMD 行界面中运行的进程。
在命令行中,它看起来像:“处理 c:/script.js 参数”。
我最初使用 Python 完成此操作:
with open("C:\path\to\document.txt", "r") as fileOpen:
lines = fileOpen.read().split("\n")
for line in lines:
subprocess.call("someProcess C:/path/to/script.js " + line, shell=True)
但是,由于需要在没有依赖关系的情况下进行分发,我现在宁愿不使用 python 来完成该任务。有没有办法使用批处理文件来做到这一点?
最佳答案
for /f "usebackq tokens=* delims=" %%# in ("C:\path\to\document.txt") do (
call "C:/path/to/script.js" %%#
)
?
关于python - 将 .txt 中的行读取到批处理文件中并作为参数传递到命令行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30756633/