Saturday, January 11, 2025
HomeProgrammingWindows - Batch script loop

Windows – Batch script loop

In Windows, a Batch script loop can be created using the for statement. The for loop iterates over a set of values, files, or commands.

Example of looping through a range of numbers:

batch
for /l %%i in (1,1,5) do (
echo Iteration %%i
)

This loops from 1 to 5, incrementing by 1.

See also  Singleton design pattern in Java

To loop through files in a directory:

batch
for %%f in (*.txt) do (
echo File: %%f
)

This iterates over all .txt files in the current directory. Batch loops are useful for automating repetitive tasks such as file manipulation or batch processing

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x