Reputation: 49
how would look for a specific string in a list of files in a given directory using batch? For example the following string RTW4OTO150227074405851I2631911150227CAC.
I Have tried this but it is not working:
for %%f in (payment.*) do findstr /i /m /p /c:"RTW4OTO150227074405851I2631911150227CAC" "%%f"" >> results.txt
Upvotes: 0
Views: 209
Reputation: 837
you can use fnr find string you want support regex plus you can recurse search all sub directory search for specific string then change to any thing you want it example
.\fnr.exe --cl --dir "c:\" --filemask "*.txt" --find "hi" --replace "bye" --includeSubDirectories
or
dir c:\ /a/b | findstr "RTW4OTO150227074405851I2631911150227CAC" >1.txt
Upvotes: 0
Reputation: 130819
There is no need for a FOR loop:
findstr /i /m /p /c:"RTW4OTO150227074405851I2631911150227CAC" payment.* >results.txt
Upvotes: 1
Reputation: 55
If Powerhsell is an option you can try
Get-ChildItem -Path C:\Myfolder -Filter RTW4OTO150227074405851I2631911150227CAC -Recurse
Upvotes: 0