Searching for files in Windows Server 2003 matching one of multiple words

1

I need to search through a disk with lots of files for any documents (PDF, DOC, DOCX, XLS, etc.) that have a file name matching one or more of a couple hundred of words.

The built-in search tool is slow and doesn't work well with many search words. Does anyone know of a tool/program that can help?

Petter Brodin

Posted 2012-12-19T12:14:30.557

Reputation: 111

Install Powershell from microsoft. The task you want to perform is a few lines long script. single for loop changing match pattern for each iteration. – mnmnc – 2012-12-19T13:15:42.890

Thanks for the suggestion. I solved the problem based on your idea. – Petter Brodin – 2012-12-20T11:00:16.250

Good to know that. cheers. – mnmnc – 2012-12-20T11:08:05.917

Answers

0

Based on the suggestion from mnmnc I made a Powershell script that seems to do the trick. It's slow, but it gives me the results I want.

$phrases = ("*Wildcard*,*separated*,*array*,*of*,*search*,*terms*")

Remove-Item .\results.txt

foreach ($p in $phrases){
    $results = @(Get-ChildItem -Recurse -Path 'E:\myPath\' -Filter "$m" | where{$_.Extension -match "doc|docx|pdf|txt|xls|xlsx"} | Select-Object Fullname)

    if($results.count -ne 0){
        $m + "      " + $results.length >> ".\results.txt"
        $results >> ".\results.txt"
        "

        " >> ".\results.txt"
    }
}

This loops through the phrases and sees if there are any files of the allowed extension that match the search phrase. The results are put into an array, and if the array has any elements the phrase, number of results, and file names are printed into a text file.

That foreach loop is probably terribly expensive and I wouldn't be surprised if there were a better way of doing it, but I'm just letting this run in the background, so I don't mind it taking a while.

Petter Brodin

Posted 2012-12-19T12:14:30.557

Reputation: 111