SysFileTree

>>-SysFileTree(filespec,stem------------------------------------>

>--+-------------------------------------------------------+---->
   +-,--+---------+--+-----------------------------------+-+
        +-options-+  +-,--+---------+--+---------------+-+
                          +-tattrib-+  +-,-+---------+-+
                                           +-nattrib-+

>--)-----------------------------------------------------------><

Finds all files that match a file specification. SysFileTree returns the file descriptions (date, time, size, attributes, and file specification) in a Rexx stem variable collection.

Parameters:

filespec

The search file specification.

stem

The name of a stem variable to be used for storing results. SysFileTree sets Rexx variable stem.0 to the number of files and directories found and stores individual file descriptions into variables stem.1 to stem.n.

options

A string with any combination of the following:

"F"

Search only for files.

"D"

Search only for directories.

"B"

Search for both files and directories. This is the default.

"S"

Search subdirectories recursively.

"T"

Return the time and date in the form YY/MM/DD/HH/MM.

"L"

Return the time and date in the form YYYY-MM-DD HH:MM:SS.

"I"

Perform a case-insensitive search for file names/directories. This option is only used on system that support case-sensitive file names and is ignored on systems like Windows where the file system is case-insensitive by default.

"O"

Return only the fully-qualified file name. The default is to return the date, time, size, attributes, and fully-qualified name for each file found.

If both the "L" and "T" options are given then the "T" option will be ignored.

tattrib

The target attribute mask for file specification matches. Only files that match the target mask are returned. The default mask is "*****". This returns all files regardless of the settings (clear or set) of the Archive, Directory, Hidden, Read-Only, and System attributes. The target mask attributes must appear in the order "ADHRS".

Target Mask Options

*

The file attribute may be any state.

+

The file attribute must be set.

-

The file attribute must be cleared.

Target Mask Examples

"***+*"

Find all files with the Read-Only attribute set.

"+**+*"

Find all files with the Read-Only and Archive attributes set.

"*++**"

Find all hidden subdirectories.

"---+-"

Find all files with only the Read-Only attribute set.

nattrib

The new attribute mask for setting the attributes of each matching file. The default mask is "*****". This means not to change the Archive, Directory, Hidden, Read-Only, and System attributes. The target mask attributes must appear in the order "ADHRS".

New Attribute Mask Options

*

Do not change the file attribute.

+

Set the file attribute.

-

Clear the file attribute.

New Attribute Mask Examples

"***+*"

Set the Read-Only attribute on all files.

"-**+*"

Set the Read-Only attribute and clear the Archive attribute of each file.

"+*+++"

Set all file attributes, except the directory attribute.

"-----"

Clear all attributes on all files.

Note: You cannot set the directory attribute on non-directory files. SysFileTree returns the file attribute settings after the new attribute mask has been applied.

Return codes:

0

Successful.

2

Not enough memory.

Examples:

/* Find all subdirectories on C: */
call SysFileTree "c:\*.*", "file", "SD"

/* Find all Read-Only files */
call SysFileTree "c:\*.*", "file", "S", "***+*"

/* Clear Archive and Read-Only attributes of files that have them set */
call SysFileTree "c:\*.*", "file", "S", "+**+*", "-**-*"

/****<< Sample Code and Output Example.>>********/

/* Code */
call SysFileTree "c:\win*.", "file", "B"
do i=1 to file.0
say file.i
end

/* Actual Output */
5:24:95   4:59p           0  -D---  C:\WINDOWS