FILELIST stage v1.4

Pipelines v2.1

 

Purpose, Operands, Streams, Usage, Examples, Related

Home

 

Syntax

 
>>───FileList───────────────┤ Location ├─────────────────────────────────────────><
    ─FList────  NOHeader─┘
    └─ListFile─┘
 
Location:
 
├──┤ Drive ├────────────┤ Path ├──┤ Filename ├──┤ Extension ├───────────────────────┤
              └─SUBdir─┘
 
Drive:
 
   ┌─DRIVEcurrent drive───────┐
├──┼───────────────────────────┼──────────────────────────────────────────────────────┤
   └──DRIVE──*─────────────┤
     └─DRV───┘ ├─drive─────────┤
                  ┌─<─,───┐   
               ─(drive─)─┘
 
Path:
 
   ┌─PATHcwd─────────────┐
         (1)             
├──┼──────────────────────┼───────────────────────────────────────────────────────────┤
   └─PATH──*─────────────┤
          ├─path──────────┤
             ┌─<─,───┐   
          ─(path───)─┘
 
Filename:
 
   ┌─FILE─*.*─────────────────────┐
├──┼──────────────────────────────┼───────────────────────────────────────────────────┤
   └──FILE───*────────────────┤
     └─RFILE─┘ ├─filename─────────┤
                  ┌─<─,──────┐   
               ─(filename─)─┘
 
Extension:
 
   ┌─EXT─*────────────────────────┐
├──┼──────────────────────────────┼───────────────────────────────────────────────────┤
   └──EXT───*─────────────────┤
     └─REXT─┘ ├─extension─────────┤
                 ┌─<─,───────┐   
              ─(extension─)─┘
 
Notes:
(1) cwd is the current working directory.
 

Purpose

 

Use the FILELIST stage to search for disk files.

 

Without operands, the FILELIST stage searches for files in the current working directory.

 

With operands, you may specify a range of drives, paths and files through which FILELIST should search. With the PATH and FILE operands, you may specify a pattern mask using the * and ? wild-card characters. When you wish to specify a list of operands, they must be separated by a comma and enclosed in parentheses. Each time FILELIST finds a file which corresponds to the operands, it writes a record to its primary output stream which comprises, the size of the file in bytes; a ten digit right-aligned field with leading spaces, the date and time when the file was last modified, a seven byte attribute mask and the fully qualified path and name of the file.

 

If the primary input stream for the FILELIST stage contains any records, FILELIST copies the records from its primary input stream to its primary output stream.

 

Operands

 

NOHeader

unless you specify the NOHeader operand; once the first file has been found which satisfies the specified search criteria; FILELIST writes a header record to the primary output stream.

 

DRIVE

DRV

specifies a drive or list of comma separated drives enclosed in parentheses.

 

 

*

specifies that all drives connected to the machine are selected.

 

 

drive

is a single character drive letter.

 

SUBdir

instructs FILELIST to search subdirectories, once the target path has been located.

 

PATH

specifies a directory path or list of comma separated directory paths enclosed in parentheses. If you do not specify the DRIVE operand, then the PATH operand specifies a subdirectory of the current working directory. Similarly, if you do not specify the PATH operand, but you do specify the DRIVE operand; FILELIST begins searching from the root directory of each specified drive. A null path is not allowed.

 

 

*

specifies that all directories are selected.

 

path

a delimited character string which specifies a target directory path.

 

FILE

specifies a filename or list of comma separated filenames enclosed in parentheses. A null filename is not allowed.

 

RFILE

specifies that filename is a regular expression or list of comma separated expressions enclosed in parentheses. A null expression is not allowed.

 

 

*

specifies that all filenames are selected.

 

 

filename

a delimited character string which specifies a target filename.

 

EXT

specifies a filetype extension or list of comma separated extensions enclosed in parentheses. A null extension is not allowed.

 

REXT

specifies that extension is a regular expression or list of comma separated expressions enclosed in parentheses. A null expression is not allowed.

 

 

extension

a delimited character string which specifies a target filetype extension.

 

Streams

 

The following streams are used by the FILELIST stage:

 

Stream

 

Action

Primary input stream

Once FILELIST has finished searching for files, FILELIST then reads records from its primary input stream, if it is connected and writes them to its primary output stream. If the FILELIST stage discovers that its primary input stream is not connected, the FILELIST stage ends.

 

Primary output stream

FILELIST writes a record detailing each file that it finds to its primary output stream.

 

Usage

 

1.

FILELIST does not delay the records.

 

2.

Once FILELIST has finished searching for files, FILELIST then reads records from its primary input stream, if it is connected and writes them to its primary output stream. If the FILELIST stage discovers that its primary input stream is not connected, the FILELIST stage ends.

 

3.

If the FILELIST stage discovers that its primary output stream is not connected, the FILELIST stage ends.

 

4.

Each output record that FILELIST writes comprises; the size of the file in bytes; a 10-digit right-aligned number with leading spaces, the date and time when the file was last modified, a seven byte attribute mask and the fully qualified path and name of the file.

 

The file attribute mask is a series of 0's and 1's that describe the attributes of the file. Each position in the mask identifies a particular attribute:

 

Byte 1 – N. a normal file (no other attributes apply)
     2 – R. read only
     3 – H. hidden
     4 – A. marked for archive
     5 – C. compressed
     6 – T. temporary
     7 – S. system

 

For example; the following header and record mask describes a read-only, compressed, system file:

 

Bytes      Date       Time     NRHACTS Filename
.......... yyyy/mm/dd hh:mm:ss 0100101 .......................

 

Note: the date is in the format: yyyy/mm/dd and the time is in twenty-four-hour format.

 

5.

If you specify a drive letter that is not defined by the system, FILELIST issues an error message and then ends.

 

6.

When you want to search the root directory of the current drive and the current working directory is not the root, you should specify the DRIVE operand with the current drive letter. The path is then relative to the root directory and not the current working directory.

 

7.

FILELIST can be specified in any position where its primary output stream is connected.

 

8.

FILELIST verifies that its secondary input and output streams are not connected and then begins execution.

 

Examples

 

In the following examples, the current working directory is:

 

D:\Pipelines\rexx

 

1.

To search for all the .txt files that begin with the character t on the root of drives D and C, in that order:

 

'pipe filelist drv (d,c) file "t*" ext "txt" | console'
 

2.

To search the current working directory for all the .txt and .exe files which are 5 characters long that begin with the letter t and end with the letter a.

 

'pipe filelist file "t???a" ext ("txt","exe") | console'

 

3.

When FILELIST processes the PATH operand, it considers the backslash (\) character to represent a directory level. Consider the following examples, in which the current working directory is:

 

D:\Pipelines\rexx

 

'pipe filelist path "stage\\debug" ext "log" | take 4 | > flist.txt'

 

flist.txt (output)

 

...|...+....1....+....2....+....3....+....4....

   **** Top of file ****

 1      Bytes Date       Time     NRHACTS Filename

 2       1851 2025/01/16 21:19:02 0001000 D:\Pipelines\rexx\stage\array\Debug\array.log

 3       1895 2025/01/16 21:19:10 0001000 D:\Pipelines\rexx\stage\between\Debug\between.log

 4       1873 2025/01/16 21:19:07 0001000 D:\Pipelines\rexx\stage\buffer\Debug\buffer.log

   **** End of file ****

 

'pipe filelist noh drive d path "\\stage\\debug" ext "log" | take 3 | > flist.txt'

 

flist.txt (output)

 

...|...+....1....+....2....+....3....+....4....

   **** Top of file ****

 1       1851 2025/01/16 21:19:02 0001000 D:\Pipelines\rexx\stage\array\Debug\array.log

 2       1895 2025/01/16 21:19:10 0001000 D:\Pipelines\rexx\stage\between\Debug\between.log

 3       1873 2025/01/16 21:19:07 0001000 D:\Pipelines\rexx\stage\buffer\Debug\buffer.log

   **** End of file ****

 

4.

To search for files on the root of a drive, (when it is not the current working directory) you must specify the DRIVE operand. The following pipeline will display all the .txt files in the C drive root directory:

 

'pipe filelist drv c ext "txt" | console'

 

5.

A filelist sorted by date and time

 

6.

Counting records

 

7.

To list every file on the machine:

 

'pipe filelist drv * subdir | console'
 

Related

 

FILEAPPEND (>>), FILEIN (<), FILEOUT (>)

 

History

 

Version

 

Date

Action

Description

Pipelines

1.4

??.??.2025

changed

Application-wide rewrite.

2.1

1.3

26.12.2021

changed

Support for the alternate stage command name: LISTFILE.

2.0

1.2

09.05.2010

changed

The file date and time values have been changed to represent 'local-time'; which brings the field's in-line with the DOS DIR and Windows file date and time property values.

1.7

changed

When FILELIST processes the PATH= operand; it now considers leading and consecutive backslash (\) characters to represent a directory name; as such you should review and amend any pipeline created under any previous version of Pipelines which uses the FILELIST stage command.

changed

FILELIST can now be specified in any position where its primary output stream is connected.

1.1

30.06.2009

added

Support for the RFILE and REXT operand; which specify that the filename and extension operands are interpreted as regular expressions, respectively.

1.6

1.0

06.09.2007

created

First version.

1.0