You are currently offline, waiting for your internet to reconnect

Using Batch Files with the FOR Batch Command

This article was previously published under Q43075
SUMMARY
If a batch file is used as the command in a FOR batch command, the FORbatch command only calls the batch file once. The following interactiveexample executes ONE.BAT for item "a", then stops:
    FOR %i IN (a b c d) DO one %i				
In a batch file, use two percent examples. The change in the exampleabove is as follows:
    FOR %%i IN (a b c d) DO one %%i				
MORE INFORMATION
In Microsoft the MS-DOS packaged product, the CALL command can be used torepeatedly execute the batch file with the FOR batch command. The aboveinteractive example is changed to the following:
    FOR %i IN (a b c d) DO CALL one %i				
This example executes ONE.BAT for each item in the list.

In releases of MS-DOS earlier than version 3.30, this can be done byspawning COMMAND.COM with the /C switch and letting it execute the batchfile. The above interactive example is changed to the following:
    FOR %i IN (a b c d) DO COMMAND /C ONE %i				
6.22 3.x 4.00 4.01 5.00 5.00a 6.00 6.20
Properties

Article ID: 43075 - Last Review: 09/30/2003 12:13:00 - Revision: 3.0

Microsoft MS-DOS 6.22 Standard Edition

  • KB43075
Feedback
&did=1&t=">r m=document.createElement('meta');m.name='ms.dqp0';m.content='true';document.getElementsByTagName('head')[0].appendChild(m);" onload="var m=document.createElement('meta');m.name='ms.dqp0';m.content='false';document.getElementsByTagName('head')[0].appendChild(m);" src="http://c1.microsoft.com/c.gif?">