View Single Post
Old 25th Aug 2019, 4:33 am   #6
arjoll
Dekatron
 
arjoll's Avatar
 
Join Date: May 2006
Location: Invercargill, New Zealand
Posts: 3,458
Default Re: Word in file search utility, DOS

FIND will do that in a basic fashion.

Often I find it's useful to search for a particular word or phrase in a number of text files - specifically scripts for an accounting package I support, looking for things like a particular table or index name. FIND was always a little clunky for that, so I just wrote a little VB.NET program to do it - the guts of it is:

Code:
Dim di As New DirectoryInfo(strPath)
Dim files = From fi In di.EnumerateFiles(strType, SearchOption.AllDirectories)

For Each fi As FileInfo In files
  Dim findstring = IO.File.ReadAllText(fi.FullName).ToLower
  If findstring.Contains(strFind) Then
    Console.WriteLine("Found in {0}", fi.FullName)
  End If
Next
strFind is the lowercase text to find, strType is the file extension, and strPath is the directory to start from. Could be just as easily done in C#. Won't be much use in MSDOS though, but you could do similar things - I'd need to fire up DOSBox and see what the options are in QuickC.
arjoll is offline