【发布时间】:2015-08-25 17:20:36
【问题描述】:
我需要逐行读取 .txt 文件的每一行,将每一行作为参数传递给我在 CMD 行界面中运行的进程。
在命令行中它看起来像:“process c:/script.js arguments”。
我最初是用 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 来完成任务。有没有办法使用批处理文件来做到这一点?
【问题讨论】:
-
您可以使用批处理脚本解析文本文件,检查它here,然后您可以像上面那样
call.js脚本
标签: python batch-file command-line-interface command-line-arguments