So I'm trying to learn the ins and outs of findstr since it's come up a few times on other batch script questions I've had. I'm trying to have it look for a word (in this case 'webview') through multiple files in a directory, ideally it would pull the line it was found as well as the file name. However, the program gets stuck in this sort of infinite loop with it and I have to force an exit. Any help on if its being caused by the findstr or what is causing it would be amazing as I've been staring at it for several hours now. My current code is below:
ECHO off
SETLOCAL enabledelayedexpansion
ECHO Please input the path to the app directory you'd like scanned
SET /p directorypath=
CD %directorypath%
ECHO Scanning files for Webview
(
FOR /F "delims=" %%a in ('findstr /I /S /M "webview" *.json') DO (
SET "line=%%a"
SET "line=!line:*webview=!"
FOR /F "delims=<" %%b in (!line!) DO ECHO %%b
)) > WebviewScanResults.txt
:eof
UPDATE: Code updated and functional for use as a reference. I pretty much just run the above code a couple of time with different file types replacing *.json and it works fine.
Just an untested try, too late for me:
@ECHO off
SETLOCAL enabledelayedexpansion
ECHO Please input the path to the app directory you'd like scanned
SET /p directorypath=
PushD "%directorypath%"
ECHO Scanning files for Webview
(
FOR /F "tokens=1*delims=:" %%a in ('findstr /I /S "webview" *.html') DO (
SET "line=%%b"
SET "line=!line:*webview=!"
FOR /F "delims=<>" %%b in ("!line!") DO ECHO %%a:%%b
)) > WebviewScanResults.txt