I dont see it getting used anywhere...Eureka! wrote: ↑30 Jan 2022 19:07Code: Select all
for /f "usebackq tokens=1 delims=:" %%I in (`findstr.exe /n /i /c:"%search%" temp1.txt`) do call :GetArchive %%I <---
search for previous item
Moderator: DosItHelp
Re: search for previous item
Just curious... What is the %%I for?
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: search for previous item
It gets referenced in :GetArchive as %1 and it tells the for loop in that subroutine how many lines to skip
Re: search for previous item
Eureka! works fast and it's perfect for my purpose, thanks as always to all
Re: search for previous item
I made a little improvement returning a full row find
Code: Select all
@echo off
set "file=report.txt"
set "search=%1"
findstr.exe /n /I /C:"#" /I /C:"%search%" "%file%" | sort.exe /r /o temp1.txt
for /f "usebackq tokens=1 delims=:" %%I in (`findstr.exe /n /i /c:"%search%" temp1.txt`) do call :GetArchive %%I
del temp1.txt
goto :EOF
:GetArchive
(for /l %%i in (1,1,%1) do set /P "row=") < temp1.txt
for /f "usebackq skip=%1 tokens=2 delims=#" %%X in (temp1.txt) do (
echo %search% %%X %row%
goto :EOF
)