Skip to content

Instantly share code, notes, and snippets.

@brovish
Created February 7, 2024 10:46
Show Gist options
  • Select an option

  • Save brovish/c43da704c63983034c4f8baf66721ac4 to your computer and use it in GitHub Desktop.

Select an option

Save brovish/c43da704c63983034c4f8baf66721ac4 to your computer and use it in GitHub Desktop.

Revisions

  1. brovish created this gist Feb 7, 2024.
    34 changes: 34 additions & 0 deletions search_info_file_v3.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    @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