Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- REM ###############################################################################################
- REM # DREP.CMD
- REM # v.2016.05.06-e
- REM # tested on Windows 10
- REM # by Nigel Warden
- REM #
- REM # can double-click or run from the command line with one
- REM # C:\>drep aNy sTriNg y0u wAnT to SeArcH
- REM # searches the contents of text files for the specified string, within the current directory
- REM # returns filenames to the console, mirroring the output to DERP_results_[date]_[time].txt
- REM # rings the bell and opens txt in notepad when finished
- REM ###############################################################################################
- setlocal ENABLEDELAYEDEXPANSION
- set count=0
- set found=0
- set lines=0
- set tym=%time:~0,-3%
- set tym=%tym::=%
- set tym=%tym: =%
- set tym=%date%_%tym%
- set ofile=DERP_results_%tym%.txt
- REM ####### a space-delimited list of file extensions to search (wildcards allowed)
- set filetypes=*.php *.*htm* *.ini .htaccess
- :AGAIN
- cls
- if "%1"=="" (
- echo.
- echo.
- set /P ask=SEARCH [%filetypes%] FILES FOR TEXT:
- ) else (
- set ask=%1
- )
- if "%ask%"=="" ( goto AGAIN )
- cls
- echo.>>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- echo ...searching [%filetypes%] files for: "%ask%">>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- echo.>>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- echo ===[ %date% %time% ]=============================================>>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- echo.>>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- for /f "delims=" %%i in ('dir /b /s %filetypes%') DO (
- findstr /M /I "%ask%" "%%i" && set /A found=!found!+1 && echo %%i>>%ofile% && set /A lines=!lines!+1
- set /A count=!count!+1
- )
- echo.>>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- echo ===[ %date% %time% ]=============================================>>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- echo.>>%ofile% && more +!lines! %ofile% && set /A lines=!lines!+1
- REM ####### "rings the bell" ... must copypasta the bell character yourself. pastebin doesn't support it. put them after the /p=
- echo | set /p=
- ping -n 2 127.0.0.1>nul
- echo | set /p=
- ping -n 2 127.0.0.1>nul
- echo | set /p=
- echo DONE. [found !found! in %count% files]>>%ofile% && more +!lines! %ofile%
- notepad %ofile%
- waitfor %RANDOM%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement