[英]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.