【发布时间】:2019-09-07 05:12:49
【问题描述】:
我正在尝试创建一个批处理文件,该文件将在 .txt 文件中搜索特定单词并根据找到的单词给我一个响应。但是当我搜索“时间”和“计时器”时,它们都会给出相同的响应,就好像它只找到了“时间”一样。有什么方法可以搜索整个单词或一系列单词,而不仅仅是单词的一部分?
我尝试过引用单词并双引号引用单词/短语,但它仍然给出相同的响应
这是一段代码:
:: Searches for the word "time" and if found, runs the file "Time.bat" in the folder, modules
:Q3
find /I "Time" CurrentConversation.txt
if errorlevel 1 (
goto :Q4
) else (
Call Modules/Time.bat
)
:: Searches for the word "timer" and if found, runs the file "Timer.bat" in the folder, modules
:Q4
find /I "Timer" CurrentConversation.txt
if errorlevel 1 (
goto :Q5
) else (
call Modules/Timer.bat
)
我预计如果文件“CurrentConversation.txt”有单词计时器,那么它将运行“Timer.bat”。如果文件有时间这个词,那么它会运行“Time.bat”,但它只会运行“Time.bat”,而不管是否存在定时器这个词
【问题讨论】:
-
因为
Time存在于Timer中
标签: string batch-file