Name
CountDirectoryEntries -- count entries in directory (V8.0)
Synopsis
n = CountDirectoryEntries(id[, what])
Function
This function can be used to count all entries in the directory specified by id. This directory must have been opened using OpenDirectory() or @DIRECTORY before.

The optional argument what can be used to specify what kind of entries should be counted. The following entry types are currently supported:

#COUNTFILES:
Count all files in the directory. This is the default.

#COUNTDIRECTORES:
Count all directories in the directory.

#COUNTBOTH:
Count both, files and directories.

Note that CountDirectoryEntries() will iterate through all entries in the directory so it must not be used during an iteration using NextDirectoryEntry(). Doing so will automatically rewind any existing directory iterations.

Inputs
id
identifier of the directory whose entries should be counted
what
optional: what should be counted (see above) (defaults to #COUNTFILES)
Results
n
number of entries of desired type in directory
Example
OpenDirectory(1, "data")
NPrint(CountDirectoryEntries(1))
The code above prints the number of files in the directory data.

Show TOC