Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I created a simple batch job that reads the third line in a file and sets the third line to a variable. the code works, it is:
@echo off
set rep=0
set report=0
for /F "usebackq delims=" %%r in ("%%a") do (
set /a rep=rep+1
if !rep!==3 (
set report=%%r
if !rep!==3 Goto :End
)
)
:EndThe third line in the file is always the title, this works, but I want it to do it for every txt file in a folder, so I put it in a larger for loop:
@echo off
for /F "usebackq delims=\ " %%a in (`dir /b *.txt`) do if not "%%a"=="results.txt" (
echo ------------------
echo Parsing %%a
echo ------------------
pause
set rep=0
set report=0
for /F "usebackq delims=" %%r in ("%%a") do (
set /a rep=rep+1
if !rep!==3 (
set report=%%r
if !rep!==3 Call :End
)
)
:End
)
This doesn't run, if I take out the ":End". It will run, but obviously not work as intended. This could easily be written in any lanuage, but dos is all I know. I mean to learn VBS at some point. Any help is greatly appreciated

GOTO within a FOR is usually challenging.
==================================
@echo off > newfile & setLocal enableDELAYedexpansionfor /f "tokens=* delims= " %%a in ('dir/b/a-d *.txt') do (
set N=
for /f "tokens=* delims= " %%i in (%%a) do (
set /a N+=1
if !N! equ 3 echo %%i >> newfile
)
)
=====================================
Helping others achieve escape felicityM2

![]() |
unable to install files f...
|
windows protection prog e...
|
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |