Create a Batch file (.bat) to search an string through multiple files

I am using Windows Server 2008 and I need to create a Batch file (.bat) to search for a given string in 20.000 to 30.000 files located all in one folder in the same level (without subfolders).

I have been searching and reading around but I couldn't find anything to do it.

Trying it with this without success:

@echo off for /r "delims=|" %%i in (*) do ( findstr /m /C:"34444" %%i
)
2

1 Answer

From batch

START cmd.exe /k "Findstr -m "34444" *.*"

From command line

Findstr -m "34444" *.*"

also from powershell, create named batch file *.cmd extension containing following content. (remember to change the gci path 'your folder path'.

@PowerShell -ExecutionPolicy Bypass -noexit -Command Invoke-Expression $('$args=@(^&{$args} %*);'+[String]::Join(';',(Get-Content '%~f0') -notmatch '^^@PowerShell.*EOF$')) & goto :EOF
gci -path 'c:\your folder path\' -fi '*' | Select-String -patt "34444" | select Filename, LineNumber | Format-Table -a

call batch file *.cmd to run the powershell search.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like