@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET /a blocksize=23
FOR /f "tokens=1*delims=:" %%a IN ('findstr /n /r ".*" 100lines.txt') DO (
SET /a progress=%%a %% %blocksize%
IF !progress!==1 IF %%a neq 1 (
REM pause here
timeout /t 10
)
ECHO(nsrjb -w -N %%b
)
GOTO :EOF
For test purposes, I set the block size to 23, and use my standard 100-lines-of-text file 100lines.txt
How you want to pause the process is your own concern. I simply used a 10-second delay using timeout
change to suit yourself.
The required nsrjb commands are merely ECHO
ed for testing purposes. After you've verified that the commands are correct, change ECHO(nsrjb
to nsrjb
to actually execute nsrjb.
It's simply a matter of numbering each line using findstr
which prefixes each line with number:
, then tokenising on first token=the number (%%a
) and second token (%%b
)=line-tail, using the colon as a delimiter.
From there, delyed-expansion is required to (calculate line-number mod block-size). If that result is 1
, then we've processed a block of lines, so wait unless the line number is 1
, which means we're about to process the very first line.
So - process a block (you choose the size), wait (you choose the time) for timeout or keypress; repeat until done.
The findstr
command converts the line in the file from
u:\dir\file.txt
to, for instance
4:u:\dir\file.txt
The for
command uses tokens = 1*
and delims = :
Taking the delims
first, what this means is "divide the line into tokens, using :
as a separator"
So 4:u:\dir\file.txt
would be split into 3 tokens, 4
u
and \dir\file.txt
.
If the tokens clause selected 1,2 and3 (tokens=1,2,3
) then the token values 4
u
and \dir\file.txt
respectively would be assigned to %%a
(the metavariable nominated in the for
instruction, %%b
and %%c
respectively (incrementing alphabetical sequence).
The special token "number" *
means `all of the line after the highest-nominated token number"
For "tokens=1*"
then, two tokens are nominated (1
and *
) so the first token value 4
is assigned to %%a
and the remainder of the line past the token separator following the highest token number nominated (1
) would be assigned to the next metavariable alphabetically (%%b
) so u:\dir\file.txt
is assigned to %%b