1

I need to read each line of a .txt file, line by line, handing in each line as an argument to a process I'm running in the CMD line interface.

In the command line it would look like: "process c:/script.js arguments".

I originally did this using 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)

However due to the need to distribute without dependencies I would now rather not use python for the task. Is there a way to do this using a batch file?

Caliban
  • 13
  • 2
  • You can parse the text file using the batch script, check it [here](http://stackoverflow.com/questions/155932/how-do-you-loop-through-each-line-in-a-text-file-using-a-windows-batch-file) and then you can `call` the`.js` script as you did it above – Bharadwaj Jun 10 '15 at 12:54

1 Answers1

2
for /f "usebackq tokens=* delims=" %%# in ("C:\path\to\document.txt") do (
    call "C:/path/to/script.js" %%#
)

?

npocmaka
  • 55,367
  • 18
  • 148
  • 187