Jump to content

Recommended Posts

Posted (edited)

Hola! :(

Does any of you guys knows a quick way to get the number of

subdirectories/files under a specific parent directory? :ph34r:

I already have an implementation with recursion in it but is still a littlel slow. I was thinking of perhaps some system command similar to "dir". Something that will give me this information almost instantly!

ElSoloMar

Edited by ElSoloMar
I am running a box with borg technology! The distintiveness of your brand box will be added to the colective ... protection utilities are futile!cha, cha, chachaaaanm!
Posted (edited)

The - 3 is necessary, because it also counts the directories "." and "..", additionally another nameless something dir (might be the behaviour of FileFindNextFile). Well, it works for me with the "-3", have a look into it on your own :ph34r:

I save @error in a variable to be able to use other functions in the loop, that change @error.

My code:

FileChangeDir("dirname")
$handle = FileFindFirstFile("*")
$counter = 0
$error = 0

While $error <> 1
    $Object = FileFindNextFile($handle)
    $error = @error
    MsgBox(0,"",$Object)
    $counter = $counter+1
WEnd

MsgBox(0,"", $counter - 3)

PS:

FileFindFirstFile:

"*" as wildcard for any file or directory

FileFindNextFile:

Failure: Sets @error to 1 if no more files/directories match the search.

Edited by Proof
Posted (edited)

Guess you could also do it with a DOS command. Don't know exactly right know, but check this Link for inspiration (or many other topics).

Edited by Proof

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
×
×
  • Create New...