How to loop command using "for" in windows ?

Hi,

I have a list of domain name, eg:

abc.domain.com
domain.com
xyz.com
123.xyz.com

The file name is domainlist.txt

May i know how to run the following command and loop :
"%plesk_cli%repair.exe" --reconfigure-web-site -web-site-name domain.com


I would like to command/script to loop change the domain.com to the domain found in the text file.

eg:

for $domain in domainlist.txt do "%plesk_cli%repair.exe" --reconfigure-web-site -web-site-name $domain


But im not sure the correct command for the above.


Please assist.



To loop through a text file line by line you can use something this


for /f "tokens=*" %%a in (input.txt) do (
echo line=%%a
)

Michael



To loop through a text file line by line you can use something this


for /f "tokens=*" %%a in (input.txt) do (
echo line=%%a
)

Michael



Hi Micheal,

Im not sure how to make it run :
"%plesk_cli%repair.exe" --reconfigure-web-site -web-site-name domain.com


The "domain.com" at the end of the line is the output obtained from the input.txt

Can you help to construct the full line for me to test ?



In a batch file (won't work on the command prompt that way):



@Qlemo,
Wouldn't it work from the command line if you made it %A instead of %%A in both locations (and, of course, domainlist.txt instead of input.txt) ?



Darr247,

Thanks for correcting, I have changed the code snippet to use the correct file ;-).
And of course it would work in the command line, if only line 3 is used, and all %% replaced by a single %. But that is something usually confusing folks not being used to it.

Share this

Related Posts

There was an error in this gadget