user73628
user73628

Reputation: 3765

Write batch file to read a number from a text file and execute the command with that number

I have a text file and a .bat file. Int the text file I have a list of workstation numbers like:

CG002681
CG002526
CG002527
CG002528
CG002529
CG002530
....

so I need to read this text file and i need to excute the command as shown below.

copy "\\cg002009\c$\Documents and Settings\All Users\Application Data\abc\LM\I4S.INI" c:\asd\mul.txt 
echo cg002009 >> c:\asd\Shashi.txt
type c:\asd\mul.txt >> c:\asd\345.txt \l

I need execute this command for each workstation.

Upvotes: 2

Views: 3855

Answers (2)

Alexey Sviridov
Alexey Sviridov

Reputation: 3490

for /F "delims= " %%i in (workstation.txt) do call handle.bat %%i

in handle.bat first param (%1) will be name of workstation there you can do all work (copy, echo and so on)

Upvotes: 1

Dirk Vollmar
Dirk Vollmar

Reputation: 176159

You can use the for command:

for /F %F in (test.txt) do echo %F

will print each line in file test.txt to the console.

Upvotes: 1

Related Questions