2020-02-07 20:11:31
1、新建一個文本名為run.bat 把以下代碼復制到run.bat里保存
::@echo off
::執行批處理文件名 "search"在"search.bat"文件中修改搜索內容
set run_name=search
set run_name_type=%run_name%.bat
::輸出log文件名
set file_name=%run_name%_log
set file_name_type=%file_name%.txt
del %file_name_type%
::日期時間
set Date=%date%
set Time=%time%
::windows使用
echo. >> %file_name_type%
echo. >> %file_name_type%
::linux使用
::printf "\n\n" >> %file_name_type%
echo %Date% >> %file_name_type%
echo %Time% >> %file_name_type%
echo %run_name_type%-^> %file_name_type% >> %file_name_type%
::linux使用
::printf "\n" >> %file_name_type%
::windows使用
echo. >> %file_name_type%
echo start-------------------------------------------------------------- >> %file_name_type%
::printf "start--------------------------------------------------------------\n" >> %file_name_type%
%run_name_type% >> %file_name_type%
::pause
2、新建一個search.bat文本,把以下代碼復制到search.bat里保存
@echo off
::[/n] 輸出行號 [/s]在當前文件夾以及子文件夾 [/i]忽略大小寫 [*.*]所以類型文件
findstr /s/n "windows" *.*
echo end--------------------------------------------------------------
3、注意上面引號里的內容windows就是要搜索的字符串,結果保存在search_log.txt文件里結果如下
兩個腳本放在要搜索的文件夾里雙擊run.bat即可。
2020/02/07 周五
20:09:27.14
search.bat-> search_log.txt
start--------------------------------------------------------------
search.bat:4:findstr /s/n "windows" *.*
搜索run.bat:15:::windows使用
搜索run.bat:28:::windows使用
end--------------------------------------------------------------