Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::This batch script attempts to find a string in files within a directory using your query.
- @echo off
- :start
- set "TEST=%~1"
- if not "%TEST%"=="" (
- set "DIRECTORY=%~1"
- goto test
- ) else (
- echo Enter the folder you would like to search in below.
- echo (Note: Subfolders will be searched as well.^)
- echo.
- set /p DIRECTORY= "Directory: "
- )
- :: ======================================================
- if "%DIRECTORY%"=="" (goto none) else (goto test)
- :none
- cls
- echo No folder selected.
- echo.
- echo Restarting search...
- timeout /t 3 /nobreak > nul
- cls
- goto start
- :test
- if exist "%DIRECTORY%" (cls & goto find)
- cls
- echo That folder does not exist.
- echo.
- echo Restarting search...
- timeout /t 3 /nobreak > nul
- set "DIRECTORY="
- cls
- goto start
- :: ======================================================
- :find
- echo A search will now be performed within the following folder:
- echo "%DIRECTORY%"
- echo.
- echo ------------------------------------------------------------------
- echo.
- echo Find what string of text?
- echo.
- set /p "FIND=Find: "
- cls
- findstr /s /i /m /c:"%FIND%" "%DIRECTORY%\*.*"
- :: ======================================================
- echo.
- echo Search completed.
- timeout /t 2 /nobreak > nul
- echo.
- pause
- cls
- set "DIRECTORY="
- goto start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement