Archive: Batch File Search


Batch File Search
i'm stuck for several hours now, i hope someone here can help me fixing my problem. i have combined two scripts which both work independently. since i combined them, the text-search doesn't work anymore.. and i have no idea why.

Name "FindHello"
OutFile "FindHello.exe"
!include "FileSearch.nsh"

Section -bla

Push $R0
FindFirst $R0 $R1 "C:\*.txt"

AVSAgain:

StrCmp $R1 "" AVSEnd


!insertmacro FileSearch "$R1" "hello"
StrCmp $1 yes 0 +2
MessageBox MB_OK "$1, was found in the file $0 times."

FindNext $R0 $R1

Goto AVSAgain

AVSEnd:
FindClose $R1

SectionEnd


help is highly appreciated!

FindFirst/FindNext return only the file name, use a full path with FileSearch.


thanks, works now.

when i try searching the attached file for "Convolution", it does not find that. so far it worked on standard .txt and .ini files, not on the attached file.

is there a solution?


..maybe i should add that avs files are basically a text-file, finding the mentioned expression works in any text-editor


That AVS file is not a normal text file, it has null characters in it. You'd have to read it using FileReadByte.


which is what i did (at least i replaced FileRead with FileReadByte), or do i have to search for a different expression then?

if so, how do i convert my plain-text search strings to work with FileReadByte?


Just replacing FileRead with FileReadByte is not enough as FileReadByte reads byte by byte and not line by line. You'd need to run FileReadByte in a loop and build a string, converting each byte to a character using IntFmt. I think Afrow UK made an example for this once. I think he even created an archive page that reads a string using FileReadByte.


super, works!