所以我试图了解findstr的来龙去脉,因为它已经出现了几次我曾经遇到的其他批处理脚本问题。我试图通过目录中的多个文件来查找单词(在本例中为#web;'),理想情况下,它会拉出找到的行以及文件名。然而,程序陷入了这种无限循环,我必须强制退出。任何帮助,如果它是由发现者引起的或由什么引起它将是惊人的,因为我现在已经盯着它几个小时。我目前的代码如下:
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
更新:代码已更新并可用作参考。我几乎只用不同的文件类型替换* .json运行上面的代码几次,它工作正常。
答案 0 :(得分:1)
只是一个未经考验的尝试,对我来说太迟了:
@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