:: Convert extensions list into a findstr include filter set "EXT_FILTER=" for %%E in (%EXTS:,= %) do ( if defined EXT_FILTER (set "EXT_FILTER=!EXT_FILTER! *.%%E") else set "EXT_FILTER=*.%%E" )
popd
:: Write CSV header set "CSV_HDR=File,LineNumber,Context,MatchType,MatchValue" if "%DRY%"=="0" ( echo %CSV_HDR%> "%OUTFILE%" ) get-keys.bat
:: Normalize paths and build exclude list for findstr set "EXCLUDE_FILTER=" for %%E in (%EXCLUDE:;= %) do ( if defined EXCLUDE_FILTER (set "EXCLUDE_FILTER=!EXCLUDE_FILTER!|%%E") else set "EXCLUDE_FILTER=%%E" ) :: Convert extensions list into a findstr include
call :mask_value "%MATCHVAL%" set "OUTVAL=%MASKED_VALUE%" REM Quote fields for CSV, replace quotes inside fields set "QFILE=%%~fF" set "QLINE=%LN%" set "QCTX=%L%" REM escape double quotes by doubling them set "QFILE=%QFILE:"=""%" set "QCTX=%QCTX:"=""%" if "%DRY%"=="0" ( >>"%OUTFILE%" echo "%QFILE%","%QLINE%","%QCTX%","%MT%","%OUTVAL%" ) echo Found [%MT%] in %%~fF:%LN% -> %OUTVAL% ) ) ) ) MatchValue" if "%DRY%"=="0" ( echo %CSV_HDR%>
REM findstr in Windows supports limited regex; some syntax above may not be portable. REM We'll use simpler multiple findstr searches per pattern below.