Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: File Search Folder Finder Extender fafOpen fafFind Binary BinaryAlloc BinaryIndexEx
Here is an example theat uses the File and Folder Finder Extender and Binary operation to search for text in a file.
;Load Appropriate Extender If WinMetrics(-2) == 3 Then AddExtender("WWFAF64I.DLL") ; 64-bit Else AddExtender("WWFAF44I.DLL") ; 32-bit searchstring = 'Read ' ; Initialize flags for readability fsHidden = 1 ; Include hidden files fsSystem = 2 ; Include system files fsRecurse = 16 ; Look in sub directories ; Open a search handle fsHandle = fafOpen(DirScript(), "*.txt", fsHidden|fsSystem|fsRecurse) filelist = '' While 1 sFoundFile = fafFind(fsHandle) If sFoundFile == "" Then Break ; Search File For Text handle = BinaryAlloc( FileSize(sFoundFile) ) BinaryRead( handle, sFoundFile ) ptr = BinaryIndexEx( handle, 0, searchstring, @FWDSCAN, 1 ) If ptr !=-1 Then filelist = ItemInsert (sFoundFile, -1, filelist, @LF) BinaryFree(handle) EndWhile If filelist == "" Pause ('Search result', ' No Files Found') Else Pause ('Search result', filelist) EndIf fafClose(fsHandle) Exit
Article ID: W17575
Filename: Search for Text in a File.txt
File Created: 2012:05:10:13:08:54
Last Updated: 2012:05:10:13:08:54