Solved Batch: For loop to read only lines starting with character

Various brands / CUSTOM BUILT
June 14, 2015 at 14:42:31
Specs: Windows 7 Professional x64, 3.6GHz 16GB
Alright, so I need to make a for loop that ALMOST works like this:
for /f "EOL=:" %%A in (file.txt) do echo %%A

The thing is that I want the EOL to be "opposite", like read only those lines starting with ":".

Is this doable with a for loop, or do I have to use another way around? if so, how?

99 little bugs in the code,
99 little bugs.
Take one down, patch it around,
129 little bugs in the code.

message edited by RainBawZ

See More: Batch: For loop to read only lines starting with character

Report •

June 14, 2015 at 19:39:46
Sure. Set ":" to the delims, take tokens 1*, and pass the "*" token to another FOR loop that does the rest of the parsing that you want.

How To Ask Questions The Smart Way

Report •

June 14, 2015 at 19:41:05
✔ Best Answer
You would need to either to filter through FINDSTR, or use an explicit test on the first char. of each line within your loop. EOL can't be inverted to my knowledge.
findstr /b ":.*"sourcfil >newfile
Or use FINDSTR within a pipe. The other way is simply:
for /f tokens=*" %%a in (sourcfil) do (
set line=%%a
if "!!ine:~0,1!" equ ":" >newfile echo !line!
Personally, I would prefer the FINDSTR method due to batch issues with special char.s

Report •

Related Solutions

Ask Question