Code: Select all
'findstr /x /v /c:"Ship sunk" "C:\Users\P Ditty\Documents\SH3\data\cfg\Backups_SCR2\!FileName5!.clg" "C:\Users\P Ditty\Documents\SH3\data\cfg\Backups_SCR2\!FileName5!.cfg"')
Repeat, I'd like to grab var5 from the second line below where the findstr (above) finds its string.
So I decided I would create a variable for the skip in the for loop. I called it "skipnumber5". However, using this variable it skips the amount of lines that I say, but then it doesn't repeat the loop. So if I set skipnumber5=12 it does not act the same as "skip=12". It does the first loop correctly, but then it repeats the first loop result again and again. Using skip=12 does work correctly with the loop,but I need skip value to change in order to grab var5 as it changes.
Code:
Code: Select all
set /a skipnumber5=0
:part5
set /a skipnumber5+=12
set /a maxlines5+=1
set /a linecount5=0
for /F "delims=" %%x in ('findstr /c:"Ship sunk" "C:\Users\P Ditty\Documents\SH3\data\cfg\Backups_SCR2\*.clg" "C:\Users\P Ditty\Documents\SH3\data\cfg\Backups_SCR2\Log_*.cfg"') do (
set /a linecount5+=1
set FileName5=
set FileName5=%%~nx
if !linecount5! GEQ %maxlines5% goto part5a
)
:part5a
set /a maxlines5a+=1
set /a linecount5a=0
for /f "skip=%skipnumber5% tokens=2 delims==" %%E in ('findstr /x /v /c:"Ship sunk" "C:\Users\P Ditty\Documents\SH3\data\cfg\Backups_SCR2\!FileName5!.clg" "C:\Users\P Ditty\Documents\SH3\data\cfg\Backups_SCR2\!FileName5!.cfg"') do (
set /a linecount5a+=1
set var5=
set var5=!var5!%%E
set /a skipnumber5+=12
if !linecount5a! GEQ %maxlines5a% (goto part5b)
)
Line in question with variable skipnumber5, in for loop options, is:
Code: Select all
for /f "skip=%skipnumber5% tokens=2 delims==" %%E in
The problem is that the skip with variable skipnumber5 is staying in the same file, skipping. But if you read the code it is supposed to change to the next Filename5, skipping. That is how it works if skip=1, or any integer.
So why is the variable skipnumber5 making skip= act this way?