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

I have a text file and a .bat file. Int in a text file I have a list of workstation numbers, for example:

CG002681
CG002526
CG002527
CG002528
CG002529
CG002530
....

      

so I need to read this text file and I need to execute 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 to execute this command for every workstation.

+2


source to share


2 answers


You can use the command : for

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

      



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

+1


source


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



in handle.bat the first param (% 1) will be the name of the workstation where you can do all the work (copy, echo, etc.)

+1


source







All Articles