Jump to content

How to find the number of directories (file, archi


Recommended Posts

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!
Link to comment
Share on other sites

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