I want to make a batch program with will display every 5th line of a text file, like line no 1, 6, 11, 16 .... I tried modifying head.bat code found here: Windows batch command(s) to read first line from text file
My code is like below:
@echo off
setlocal enabledelayedexpansion
if [%1] == [] goto usage
SET /a counter=0
for /f "usebackq delims=" %%a in (%1) do (
set /a testcond=(%%counter-1)%4
if "!testcond!"=="0" echo %%a
set /a counter+=1
)
goto exit
:usage
echo Usage: fifth FILENAME
:exit
This code is not working. Can you please tell me what is the wrong with this code?