Sign in to follow this  
Followers 0
milchkuh1988

Count Files in a Directory

6 posts in this topic

Hi

How can I count the Files in a Directory???? Can somebody sent me a Script.. please???

Share this post


Link to post
Share on other sites



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 !

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
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.")
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

Share this post


Link to post
Share on other sites

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Also you can use _FileListToArray()

see help

8)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0