Categories
Scripts Windows Batch

For Loop

09ForLoop.bat

::This program is used to demonstrate the for loop structure

@echo off

::For loop to iterate over list of values
echo print the list by for loop
for %%v in (11 22 33 44 55) do echo "v :: %%v"

::For loop to iterate through content of directory
echo print list of files in current directory
FOR %%v IN (.\*) DO ECHO %%v


echo To iterate over range from 10 to 100 with increment of 20 each iteration
::For loop to iterate over range
:: /L signifies to iterate over range
for /L %%v IN (10, 20, 100) Do echo "v :: %%v"



output

Leave a comment

Design a site like this with WordPress.com
Get started