compact21 0 Posted May 2, 2014 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 expandcollapse popup;==========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 EndIf EndIf EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then ; If file is a Directory then pass through Search($current & "\" & $file, $ext) EndIf WEnd FileClose($search) EndFunc Share this post Link to post Share on other sites
abberration 53 Posted May 2, 2014 Perhaps you might want to look at this UDF by the super awesome member named guinness: '?do=embed' frameborder='0' data-embedContent>> Easy MP3 | Software Installer | RAID Calculator Share this post Link to post Share on other sites