Jump to content

Count Files in a Directory


Recommended Posts

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

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 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

  • 1 year later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...