FileFind

(Engine-Level Function)

Description: Performs a recursive search down through the directory tree structure and returns an array of matching file names.
Returns: Array
Usage: Script only.
Function Groups: File I/O
Related to: FindFile | Dir | DriveInfo | FileDialogBox | GetFileAttribs
Format: FileFind(Path, Attributes, Option)
Parameters: .
Path  
Required. Any text expression that indicates the full path name where the search begins. This may include a wildcard spec, such as "*.DAT". The search progresses recursively down each sub-directory (depth-first).
Attributes  
Required. Any numeric expression that gives the attributes to match on each file listed (files not matching these attributes won't be listed).

Attribute

Bit No.

Meaning

0

-

Files without attributes

8

3

All files (regardless of attributes)

Alternatively, the parameter may be constructed by adding together the numbers from the table below:

Attribute

Bit No.

Meaning

1

0

Read only

2

1

Hidden

4

2

System

16

4

Sub-directory

32

5

Archive

Option  
Required. Any numeric expression giving the type of text information to generate. The options are chosen by adding together all of the option numbers required.
All information is placed in a single text string, separated by spaces. It will be stored in an element of the array that is created. The information is written from left to right, with lowest option numbers first.

Option

Bit No.

Generates

1

0

Short file name

2

1

Full path and file name

4

2

File size

8

3

File last modified date (in text)

16

4

File last modified time (in text)

32

5

File attributes (ADHRS)

64

6

File last modified date/time combination (in secs since Jan. 1, 1970)

128

7

File creation date (in text)

256

8

File creation time (in text)

512

9

File creation date/time combination (in secs since Jan. 1, 1970)

The attributes returned as a result of bit 5 being set are printed as the capital letters A (archive), D (subdirectory), H (hidden), R (read-only), and S (system).

Comments:

This function returns an array of text values. As the function does a recursive search through the directory tree, the contents of each sub-directory are added to the array in reverse-alphabetic order before the function moves on to the next directory.
Each text value contains the information specified by Option for each file which matches both Path and Attributes. If no files are found, the return value will be set to invalid. Notice that the only difference between this function and the Dir function is that Dir searches in the immediate directory only, while this function looks down through the whole directory tree.

(See: Bitwise Parameters & Operations)

Example:

  If 1 Main;
  [
    FileData = FileFind("C:\VTScada\App\*.DAT", 8, 8);
  ]

This statement will find all files with the extension "*.DAT" in the given directory regardless of their attributes. The array fileData will contain each file's full path and file name as well as its size and date.