Jump to content
Sign in to follow this  

Help optimizing a Search script

Recommended Posts


Hi, i keep all my text, au3, html etc. files on my external hdd and i tryed to create kind of a search script, now that the script is done, i want to optimize it for a fast search avoiding errors, i just have one question, and i am opened for ideeas...the question is commented in the script. So please help me and clean my script! thanx

;==========Var section===========

$current = "G:\"

$ext = ".txt"

$ext2 = ".au3"

$string = "array"

$string2 = "pixel"

;=========End of Var section===========

Search($current, $ext) ;calling function Search

Func Search($current,$ext)  ;defining function Search

Local $search = FileFindFirstFile($current & "\*.*")

While 1 ; Loop for finding files

Dim $file = FileFindNextFile($search)

If @error Or StringLen($file) < 1 Then ExitLoop ;exit on error

If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then ;verify if is a directory

If StringInStr($current & "\" & $file, $ext) Or StringInStr($current & "\" & $file, $ext2) then ; if it's not a directory verify the extension ..... should i use the variable defined in Var section or the extension like .au3 or .txt

$open = FileOpen($current & "\" & $file, 0) ; open file for reading

$read = FileRead($open)

If StringInStr($read, "array") Or StringInStr($read, "pixel") Then  ;Should i use the variable defined in Var section like $string or i should use directly the keyword like "pixel"

MsgBox (0, "File ", "Found " & $current & $file & "  Containing: " & $read)

FileWriteLine(@WorkingDir & "\LogFile.txt","The file is: " & $current & $file & "  Containing: " & $read) ; Create a log file




If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then ; If file is a Directory  then pass through

Search($current & "\" & $file, $ext)





Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.