0

已经查看了网络,但找不到任何可以提供帮助的东西。我正在尝试制作一个可以删除页面内容的页面。已设法进行搜索,可以告诉您 .txt 文件中是否有单词。我怎么把它放进去?

cls
set /p SEARCH= Please enter what you want to look for?

for /f "Delims=" %%a in (test.txt) do (

set FIND=%%a

)

if %SEARCHS%==%FIND% goto FLIGHT HAS ARRIVED
echo We were not able to find %SEARCH%
pause
goto start

有人知道我应该怎么做吗?

谢谢,亚历克斯

4

2 回答 2

1
type file|find "string in lines to remove" /i /v >newfile

可能有帮助。
set /p reg=text:
for /f "delims=" %%i in (file.txt) do if %%a'==%reg%' goto found
我不知道你想做什么,所以如果这没有帮助,请详细说明。

于 2013-10-07T17:35:08.477 回答
0

尝试这个:

@ECHO OFF &SETLOCAL 
set /p "SEARCH= Please enter what you want to look for? "
for /f "Delims=" %%a in ('find "%SEARCH%" test.txt') do set "FOUND=%%a"
if DEFINED FOUND goto FLIGHT_HAS_ARRIVED
echo We were not able to find %SEARCH%
pause
goto start

:FLIGHT_HAS_ARRIVED
ECHO %SEARCH% found: %FOUND%
goto:eof

您不应将 cmd 命令名称用于变量名称 ( %FIND%)。
如果跳转标签包含空格,则跳转标签无法按预期工作:FLIGHT HAS ARRIVED

于 2013-10-07T18:14:54.533 回答