writerturtle Posted April 10, 2016 Posted April 10, 2016 When this bit of script runs, the console shows that directories that FileGetAttrib() is run on are returning empty strings, instead of strings that contain a D. What could be causing this? While 1 $file = FileFindNextFile($filehandle) If @error Then ConsoleWrite("Error in SearchDir") ; ExitLoop EndIf $aPathSplit = _PathSplit($file, $sDrive, $sDir, $sFileName, $sExtension) If $file <> '.' And $file <> '..' Then $att = FileGetAttrib($file) ;$dir & $file) ConsoleWrite(" SearchDir is examining " & $file & "which is " & $att & @CRLF) If StringInStr($att, "D") > 0 Then ;<------ checks if file is a directory SearchDir($dir & "\" & $file, $dirToCheck) FileChangeDir($dir) EndIf EndIf WEnd
writerturtle Posted April 10, 2016 Author Posted April 10, 2016 Actually, it looks like empty strings are returned for all the files and folders searched except for the first 10 or so files.
AutoBert Posted April 10, 2016 Posted April 10, 2016 This works perfect for me: #include <File.au3> Local $sDrive, $sDir, $sFileName, $sExtension $filehandle=FileFindFirstFile('*.*') While 1 $file = FileFindNextFile($filehandle) If @error Then ConsoleWrite("Error in SearchDir") ; ExitLoop EndIf ConsoleWrite($file) $aPathSplit = _PathSplit($file, $sDrive, $sDir, $sFileName, $sExtension) If $file <> '.' And $file <> '..' Then $att = FileGetAttrib($file) ;$dir & $file) ConsoleWrite(" SearchDir is examining " & $file & "which is " & $att & @CRLF) If StringInStr($att, "D") > 0 Then ;<------ checks if file is a directory ;SearchDir($sdir & "\" & $sfile, $dirToCheck) FileChangeDir($sdir) ConsoleWrite('Dir Changed'&@CRLF) ;Exit EndIf EndIf WEnd seems you used wrong var $dir instead of $sDir.
writerturtle Posted April 10, 2016 Author Posted April 10, 2016 46 minutes ago, AutoBert said: This works perfect for me: #include <File.au3> Local $sDrive, $sDir, $sFileName, $sExtension $filehandle=FileFindFirstFile('*.*') While 1 $file = FileFindNextFile($filehandle) If @error Then ConsoleWrite("Error in SearchDir") ; ExitLoop EndIf ConsoleWrite($file) $aPathSplit = _PathSplit($file, $sDrive, $sDir, $sFileName, $sExtension) If $file <> '.' And $file <> '..' Then $att = FileGetAttrib($file) ;$dir & $file) ConsoleWrite(" SearchDir is examining " & $file & "which is " & $att & @CRLF) If StringInStr($att, "D") > 0 Then ;<------ checks if file is a directory ;SearchDir($sdir & "\" & $sfile, $dirToCheck) FileChangeDir($sdir) ConsoleWrite('Dir Changed'&@CRLF) ;Exit EndIf EndIf WEnd seems you used wrong var $dir instead of $sDir. That's actually just referring to a variable declared outside the while loop which is redundant (they're one in the same). I know that the thing causing my problem is that this recursive function is calling another recursive function. If I cancel the other, the program works as intended. But I'd have to post the entire 400 line code to show what I mean, which nobody wants to look through. Thanks for the help, and for confirming the problem is not happening in this particular loop
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