Tektodon Posted June 6, 2006 Share Posted June 6, 2006 Hey, I need a (simple) way to count all files in a directory AND it's subdirectories. $d = FileFindFirstFile($tmp&"\*") While 1 $dfile = FileFindNextFile($d) If @error Then ExitLoop If StringLeft($dfile,1) <> "." And StringLeft($dfile,1) <> ".." And StringLeft($dfile,1) <> "~" Then $counttemp = $counttemp +1 Else EndIf WEnd Already tried that, but this of course does not count files in subdirs(which's names are random!). On the other hand it is absolutely nesessary that the function does NOT count the subdirs itself. Link to comment Share on other sites More sharing options...
Daniel W. Posted June 6, 2006 Share Posted June 6, 2006 (edited) Global $number = 0 $search = FileFindFirstFile("C:\*.*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $number += 1 WEnd FileClose($search) MsgBox(0,"", $number) Should work Hmm you need to count the files for all subdirectories i think! Edited June 6, 2006 by Daniel W. --------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote] Link to comment Share on other sites More sharing options...
mr.underperson Posted June 6, 2006 Share Posted June 6, 2006 Maybe something like this... $total = 0 _CountFilesRecursive("C:\some\folder") MsgBox(0, "total", $total) func _CountFilesRecursive($dir) $handle = FileFindFirstFile($dir & "\*.*") while 1 $file = FileFindNextFile($handle) if @error then exitloop if StringInStr(FileGetAttrib($dir & "\" & $file), "D") and ($file <> "." or $file <> "..") then _CountFilesRecursive($dir & "\" & $file) else $total += 1 endif wend FileClose($handle) endfunc -mu Link to comment Share on other sites More sharing options...
ChrisL Posted June 6, 2006 Share Posted June 6, 2006 What is wrong with DirGetSize( "path" ,1) [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
mr.underperson Posted June 6, 2006 Share Posted June 6, 2006 too easy. -mu 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