milchkuh1988 Posted February 25, 2006 Share Posted February 25, 2006 Hi How can I count the Files in a Directory???? Can somebody sent me a Script.. please??? Link to comment Share on other sites More sharing options...
oleg Posted February 25, 2006 Share Posted February 25, 2006 DirGetSize -------------------------------------------------------------------------------- Returns the size in bytes of a given directory. DirGetSize( "path" [, flag] ) Parameters dest dir The directory path to get the size from, eg. "C:\Windows". flag [optional] this flag determines the behaviour and result of the function, and can be a combination of the following: 0 = (default) 1 = Extended mode is On -> returns an array that contains extended information (see Remarks). 2 = Don't get the size of files in subdirectories (recursive mode is Off) Return Value Success: Returns >= 0 the sizes Failure: Returns -1 and sets @error to 1 if the path doesn't exist. Remarks If the script is paused then this function is paused too and will only continue when the script continues! If you use the extended mode then the array returned from this function is a single dimension array containing the following elements: $array[0] = Size $array[1] = Files count $array[2] = Dirs Count Related None. There is a hex ( 31303030303030 ) reasons i love AutoIt ! Link to comment Share on other sites More sharing options...
theguy0000 Posted February 25, 2006 Share Posted February 25, 2006 (edited) Welcome to AutoIt! simplifying oleg's reply: $size = DirGetSize("C:\path\to\somewhere\on\your\computer", 1) $number_of_files = $size[1] MsgBox (0, "info", "the directory contains "&$number_of_files&" files.") Edited February 25, 2006 by theguy0000 The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
n9mfk9 Posted May 6, 2007 Share Posted May 6, 2007 Welcome to AutoIt! simplifying oleg's reply: $size = DirGetSize("C:\path\to\somewhere\on\your\computer", 1) $number_of_files = $size[1] MsgBox (0, "info", "the directory contains "&$number_of_files&" files.")hi theguy0000, I tried that code an got non-Array variable.: $number_of_files = $size[1] $number_of_files = $size^ ERROR how do i fix this error Link to comment Share on other sites More sharing options...
Valuater Posted May 6, 2007 Share Posted May 6, 2007 try this $size = DirGetSize(@ScriptDir, 1) $number_of_files = $size[1] MsgBox (0, "info", "the directory contains "&$number_of_files&" files.") I am guessing you did not change the folder of where to search 8) Link to comment Share on other sites More sharing options...
Valuater Posted May 6, 2007 Share Posted May 6, 2007 Also you can use _FileListToArray() see help 8) 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