PcExpert Posted September 14, 2006 Share Posted September 14, 2006 Hi, Is it possible to count the number of files that are in a specified directory? Thanks! Link to comment Share on other sites More sharing options...
p)(d Posted September 14, 2006 Share Posted September 14, 2006 $search=FilefindFirstFile("C:\dir\*.txt") while 1 $file = FileFindNextFile($search) if @error then exitloop $countfiles += 1 wend fileclose($search) this counts all *.txt in c:\dir SYS 64738 Link to comment Share on other sites More sharing options...
Uten Posted September 14, 2006 Share Posted September 14, 2006 No offence but this is a kind of hilarious question from someone with your kind of nick Anyhow, modify the sample provided in the help file for FileFindNextFile and you should be set. If you want to filter out the folders you could do so by checking the result from FileGetAttrib. Happy coding Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
Don N Posted September 14, 2006 Share Posted September 14, 2006 ;change the working directory FileChangeDir( ".\temp" ) ;get the first file $search = FileFindFirstFile( "*.*" ) If $search = -1 Then MsgBox( 0, "ERROR!", "There are no files or could not connect to remote directory" ) EndIf Dim $fileCount = 0 While 1 $file = FileFindNextFile( $search ) If @error Then ExitLoop EndIf If StringInStr( FileGetAttrib( $file ), "D" ) == 0 Then $fileCount += 1 EndIf WEnd MsgBox( 0, "File Count", "Found " & $fileCount & " files." ) _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper Link to comment Share on other sites More sharing options...
Valuater Posted September 14, 2006 Share Posted September 14, 2006 with 219 posts, i would think this was an easy one ???? #Include <File.au3> $FileList=_FileListToArray(@DesktopDir, "*.*", 1) If (Not IsArray($FileList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf MsgBox(64,"File Count", "Files in folder = " & $FileList[0]) 8) Link to comment Share on other sites More sharing options...
blademonkey Posted September 14, 2006 Share Posted September 14, 2006 with 219 posts, i would think this was an easy one ???? #Include <File.au3> $FileList=_FileListToArray(@DesktopDir, "*.*", 1) If (Not IsArray($FileList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf MsgBox(64,"File Count", "Files in folder = " & $FileList[0]) 8)Quantity of Posts <> Knowledge of Autoit ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
Valuater Posted September 14, 2006 Share Posted September 14, 2006 Quantity of Posts <> Knowledge of AutoitQuantity of Posts = Knowledge of Autoit's Help File8) Link to comment Share on other sites More sharing options...
/dev/null Posted September 14, 2006 Share Posted September 14, 2006 Hi, Is it possible to count the number of files that are in a specified directory? Thanks! Look at the extended mode of DirGetSize(). $retArray = DirGetSize("C:\",1) $nFiles = $retArray[1] $nDirs = $retArray[2] BTW: Think about error checking!! See help file sample. Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Uten Posted September 14, 2006 Share Posted September 14, 2006 Hi @Kurt, Nice pointer to the DirGetSize. I did not know that one, so I guess I'm still learning Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling 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