there doesn't seem to be a batch script tag.
That's probably because the .bat script syntax is outdated and, in my opinion, just terrible. Powershell is a much better choice as a scripting language.
The added benefit is that as you become more familiar with Powershell, you can use it for all kinds of support tasks.
cls
$SearchDir = "c:\utils"
$Keywords = "IIS", "invoke-command", "xyzzy"
$results = @()
foreach ($kw in $Keywords) {
Write-Host "Searching for $kw"
foreach ($f in (Get-ChildItem -Path $SearchDir -recurse -File)) {
$search = Select-String -Path $f.fullname -Pattern $kw
if ($search.count -gt 0) {
$results += [PSCustomObject]@{
KeyWord = $kw
Count = $search.count
File = $f.FullName
}
}
}
}
Write-Host "Here is what I found."
$results # show the results
# Uncomment to save the results to a file
# $results | Out-File C:\Temp\results.txt
# $results | Export-Csv -Path "c:\temp\results.csv" -NoTypeInformation
Use Powershell_ISE to develop and test the code.
https://www.bing.com/search?q=powershell+tutorial