FILEFIND.GET()

Syntax

FILEFIND as C = FILEFIND.GET( File_Pattern as C [, File_Attribute as C [, Format_String as C ]] )

Argument

Description

File_Pattern

A pattern to select file names using wildcard characters like ‘*’ and ‘? ’.

File_Attribute

Optional. Default = 0 (normal files). The File_Attribute parameter is a numeric value specifying the type of file to find. You can find files that have one or more of the following attributes:

File Attribute

Description

FILE_FIND_NORMAL

Normal

FILE_FIND_READONLY

Read-only

FILE_FIND_HIDDEN

Hidden

FILE_FIND_SYSTEM

System

FILE_FIND_LABEL

Label

FILE_FIND_DIRECTORY

Directory

FILE_FIND_ARCHIVE

Archive

FILE_FIND_AND_FLAGS

Specifies that multiple flags should be ANDed together rather than ORed. By default flags are ORed.

FILE_FIND_NOT_READONLY

Files that are NOT readonly

FILE_FIND_NOT_DIRECTORY

Files that are NOT directory files

FILE_FIND_NOT_ARCHIVE

Files that do not have their archive bit turned on.

FILE_FIND_AND_NOT_FLAGS

Specifes that when multiple "NOT" flags are used that the flags should be ANDed together.

Format_String

Specifies the type of file to retrieve. The format string can contain these characters:

  • "P" = Path

  • "N" = Filename

  • "D" = Directory - "d" if file is a directory, "-" if not.

  • "H" = Hidden - "h" if file is hidden, "-" if not.

  • "S" = System - "s" if file is a system file, "-" if not.

  • "T" = Date and time file was last updated

  • "L" = Size

  • "C" = Creation date and time

  • "R" = Last time read

  • "A" = Archive bit

  • "X" = DOS short name (8.3), if the file is a long file name

The format characters, D, H and S can be followed by optional true and false values enclosed in parentheses. E.g. the format string " D(directory - )(file - )N " would list entries in a folder. Each entry would be prefixed with either " directory – ", or " file – ", depending on its type. The C, R and T options can be followed by ( Format_String ). See TIME() function for Format_String options.

Description

The FILEFIND.GET() method creates a CR-LF delimited string with information about the files in a directory that match a pattern. The format string controls the format in which the information is returned.

Example

The following script populates an array with information about the files in a folder. The '0' attribute is used to select normal files. The format string returns the fullname, the directory flag, and the date time stamp. The information is displayed in a dialog box.

list = filefind.get("f:\a5v5\*.*",0,"PN|D|T")

format = "name|directory|time"

dim pp[2000] as P

pp.initialize_properties(format,list)

dim indx as N

indx = 1

ui_dlg_box("Display File Information",<<%a%

Name|Directory|Time;

[.30,20indx^#pp[\].name]|[.10,20indx^#pp[\].directory]|[.40,20indx^#pp[\].time];

%a%)

How To Identify an Empty Directory

The following script determines if a directory is empty.

dim path as C

dim FILEFIND as C

path = "YOUR DIRECTORY"

FILEFIND = filefind.get(path + "\*.*", FILE_FIND_NOT_DIRECTORY, "N")

if (FILEFIND = "") then

'The directory is empty

end if

See Also

FILEFIND Methods, File Functions and Methods

Supported By

Alpha Five Version 5 and Above