Read and Process a File line by line |
The following shows how each line of a text file can be processed:
@echo off setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION REM *** Example 1 *** dir *.exe /b > SomeFile.TXT for /F "delims=" %%f in (SomeFile.TXT) do echo LINE: %%f REM *** Example 2 (filename contains spaces, use "usebackq") *** set MatchCnt=0 for /F "usebackq delims=" %%d in ("Some File.TXT") do ( set /A MatchCnt=!MatchCnt! + 1 echo #!MatchCnt! : %%d ) echo Found %MatchCnt% Lines