Soldato
Does anyone know of a program that will allow me to search within a bunch of text files for any words in a list which are stored in another text file?
param(
[Parameter(Mandatory = $true, Position = 0)]
[string]$directory,
[Parameter(Mandatory = $false, Position = 1)]
[string]$wordFile = "C:\Scripts\files\words.txt"
)
$words = get-content $wordFile
$regex = "(?i)" + ($words -join "\b|") + "\b"
$matched = get-childitem $directory -filter *.txt | get-content | foreach {[regex]::matches($_, $regex)} | %{ $_.Groups[0].Value } | select -Unique
$not_matched = @()
foreach($word in $words)
{
if($matched -notcontains $word)
{ $not_matched += $word }
}
Write-Host "`nSearching all text files found in '$directory' for the words:"
Write-Host "`n$words" -fore cyan
Write-Host "`n`nWords Found" -fore green
Write-Host $matched
Write-Host "`nWords NOT Found" -fore red
Write-Host $not_matched
Does anyone know of a program that will allow me to search within a bunch of text files for any words in a list which are stored in another text file?
I assume you have used PowerShell before. If not let me know and I will write the couple of steps you need to do. I would link to a post where ive explained it before, but can't find any!
Notepad++ almost does this....
I had to set the security to Unrestricted (found this out with a bit of Googling) and I changed it to search in *.xml files. It is running now and taking up 50% of CPU... been like that for a few minutes now, so lets see what happens
Set-ExecutionPolicy RemoteSigned
SiriusB... I love you!