Created
February 7, 2024 10:46
-
-
Save brovish/c43da704c63983034c4f8baf66721ac4 to your computer and use it in GitHub Desktop.
search_info_file_v3.cmd c:\temp file.ini string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal EnableDelayedExpansion | |
| if "%~3"=="" ( | |
| echo Incorrect usage. The correct usage is: %~nx0 "Search Directory" "Filename Pattern" "Search String" | |
| exit /b | |
| ) | |
| set "SEARCH_DIR=%~1" | |
| set "FILENAME_PATTERN=%~2" | |
| set "SEARCH_STRING=%~3" | |
| set "TEMP_FILE=%TEMP%\filelist.txt" | |
| dir /S /B "%SEARCH_DIR%\%FILENAME_PATTERN%" > "%TEMP_FILE%" | |
| for /F "delims=" %%F in (%TEMP_FILE%) do ( | |
| findstr /M /I /C:"%SEARCH_STRING%" "%%F" >nul | |
| if !errorlevel! equ 0 ( | |
| echo Contains string: "%%F" | |
| ) else ( | |
| echo Does not contain string: "%%F" | |
| ) | |
| ) | |
| del "%TEMP_FILE%" | |
| endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment