Code: Select all
<%1 (
SET "B_ID=!LO!" & SET "NDX2=!LO!"
for /L %%j in (!LO!,1,!HI!) do (
SET "LN=" & SET /P "LN="
if "!LN:~-2!"=="*]" (
SET /A B_ID+=1
FOR %%a IN (!B_ID!) DO SET /A NDX2=!V_%%a!
)
ECHO !NDX2! %%j ]!LN!
)
) > %2
It uses an array of variables V_100001 through to V_100771 - with room for expansion
I dislike the exponential growth of execution time as the size of the array V_nnnnnn increases.
Is there a quick easy way to read a sequence of numbers from a file so that I can avoid using the array ?
My code prefixes each line from %1 with an index number and a line count, giving a 6000 line output to %2 of which this is a portion
Code: Select all
100001 100012 ]
100004 100013 ][.Thumbnails*]
100004 100014 ]LangSecRef=3021
100004 100015 ]DetectFile=%UserProfile%\.Thumbnails
100004 100016 ]Default=False
100004 100017 ]FileKey1=%UserProfile%\.Thumbnails|*.*|RECURSE
100004 100018 ]
100002 100019 ][.NET Framework Logs*]
100002 100020 ]LangSecRef=3025
100002 100021 ]DetectFile=%WinDir%\Microsoft.NET
100002 100022 ]Default=False
100002 100023 ]FileKey1=%WinDir%\Microsoft.NET|*.log|RECURSE
100002 100024 ]
100003 100025 ][.NET Reflector*]
The purpose is to prepare the file for
SORT %2 > Sorted.ini
so that Block B_ID 100004 100013_through_to10018 will follow Block B_ID 100003 etc following B_ID 10002 etc
Regards
Alan