qazwsx Posted August 25, 2008 Share Posted August 25, 2008 Here is my attempt at a function to search the entire computer for all of a certain type of file: Func _findBats ($folder) local $search = FileFindFirstFile ("*.txt") If $search <> -1 Then;looks to bat files While 1 local $file = FileFindNextFile ($search) If @error = 1 then ExitLoop;no more files MsgBox (0, "", $file) WEnd EndIf $folders = _FileListToArray ($folder, "*", 2);gets other folders and checks them If @error = 4 then Return For $i = 1 to $folders[0] _findBats ($folder & $folders[$i] & "\") Next EndFunc It returns the same to file names over and over again. Neither of which are in my c drive. Any help is appreciated. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 25, 2008 Share Posted August 25, 2008 (edited) You forgot to tell FileFindFirstFile() which folder it should search, try this:#Include <File.au3> _findBats("C:\") Func _findBats ($folder) local $search = FileFindFirstFile ($folder & "*.txt") If $search <> -1 Then;looks to bat files While 1 local $file = FileFindNextFile ($search) If @error = 1 then ExitLoop;no more files ;~ MsgBox (0, "", $file) ConsoleWrite($file & @CRLF) WEnd EndIf $folders = _FileListToArray ($folder, "*", 2);gets other folders and checks them If @error = 4 then Return For $i = 1 to $folders[0] _findBats ($folder & $folders[$i] & "\") Next EndFuncEDIT: You forgot to close the search handle! You should add FileClose($search) after the while loop! Edited August 25, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
qazwsx Posted August 25, 2008 Author Share Posted August 25, 2008 ohh thank you, not sure how i missed that, and good call on consolewrite Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now