VBScript or batch file to search a directory for a certain file name, count the occurances of a string within each file
Posted on 2008-11-17
I have a number of reports that are emailed and saved as .msg files to a directory on a daily basis. I'm looking for some VBScript that will do the following:
1. Search the directory (lets say '\\directory') for all files named 'report.msg'. Note that the directory is structured as follows:
Files named 'report.msg' could lie anywhere within the directory structure.
2. For every 'report.msg' file, count the occurances of a particular string, say 'xyz'. The end result would be a Results.txt file looking something like:
<FilePath>, <SearchString>, <NumberOfOccurances>
//directory/2008/1-2008/1-1-2008/report.msg, xyz, 10
3. It would be best if the script could prompt the user for the directory (ex. '//directory'), file name (ex. 'report.msg'), and search string (ex. 'xyz').
-Thanks for the help!