繁体   English   中英

将.txt中的行读取到批处理文件中并作为参数传递到命令行中?

[英]Reading lines from .txt into batch file and handing into command line as arguments?

我需要逐行阅读.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" %%#
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM