Link to home
Start Free TrialLog in
Avatar of D B
D BFlag for United States of America

asked on

Search Folder Recursively and Report "No matches"

This is a 'continuation' of this question.

Originally, I had asked that, given a list of keywords, and a pointer to a folder, I would like to display all occurrences of where any of the keywords were found, and indicate if no matches were found for that keyword. I have over 300 keywords and about 250 SQL scripts that make up several hundred thousand lines of code, so I am changing the requirements somewhat (although I am impressed how fast PowerShell does this).

The reason for showing lines that included the keywords was so I could check for scenarios where a substring was found (like I_FIS as a keyword found in I_FIS_REJECT), but the output is overwhelming.

Having executed the code suggested in the above link, I am refining the parameters.
First of all, the keywords are table names, and I am checking code to see if the table is referenced. As such, the keyword would almost always be either a full word (such as SELECT * FROM mytable) or be prefixed with a period (.), such as SELECT * FROM dbo.mytable). There should always be whitespace in the form of a space or CR/LF following the keyword, as shown by these examples:
SELECT *
FROM dbo.mytable
WHERE 1 = 1
or
SELECT *
FROM mytable t
WHERE 1 = 1

I want the search and report to be case insensitive, such that, if my keyword is "mytable", "MyTable" and "MYTABLE" count as a match, and I want to report where the keyword is NOT FOUND.

My original request just stated that I would search a folder and subfolders for any file, but I only want to search files with a file type of ".SQL"

The output only has to list the keywords from the list that were not found in any of the scripts.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D B

ASKER

Fantastical!!!