| Subcribe via RSS

How-to: FOR loop inside a FOR loop in batch

October 14th, 2010 Posted in Scripting, Windows

How to do a FOR loop inside a FOR loop in batch?
How to do nested FOR loops in batch?

Example:
@echo off
setlocal EnableDelayedExpansion EnableExtensions
for /F %%a in (file.txt) do (
set file_content=%%a
for /f "tokens=*" %%k in (' %file_content%') do (
set command_result=%%k
echo !file_content! !command_result!
)
)
ENDLOCAL

Leave a Reply

technoblog@trap.threatobs.com