# $file-names(5)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

$file-names - Filtered file name list

## SYNOPSIS

$file-names FileName

## DESCRIPTION

$file-names must first be initialized to the required filter string, if the variable is evaluated before it is initialized the value will be set to "ABORT" and the command will fail.

The filter takes the form of a regex. The filter string should also contain the path to the required directory, the path many not contain wild-cards. If no path is specified the the path of the current buffers file name is taken, if the current buffer has no file name then the current working directory is used.

On initialization, $result(5) is set to the absolute path of the directory being evaluated.

Once initialized, evaluating $file-names returns the name of the next buffer which matches the filter until no more buffers are found, in which case an empty string is returned.

## EXAMPLE

The following example creates a list of all files in the current directory to a fixed buffer "*files*". Note that &set(4) is used on the !while(4) statement to avoid evaluating $file-names twice per loop.

    set-variable $file-names ".*"
    !force 0 delete-buffer "*files*"
    1 popup-window "*files*"
    insert-string &spr "Directory listing of %s\n\n" $result
    !while &not &seq &set #l0 $file-names ""
        insert-string &spr "    %s\n" #l0
    !done
    beginning-of-buffer
    -1 buffer-mode "edit"
    1 buffer-mode "view"

## NOTES

Unlike MS-DOS and Windows systems, to match every file a filter of just "*" is required. A filter of "*.*" only matches file names with a '.' in them.

The list of files is evaluated when the variable is initialized, files created after the initialization will not be included in the list.

## SEE ALSO

$result(5), find-file(2), $buffer-fname(5), $buffer-names(5), $command-names(5), $mode-names(5), Regular Expressions.

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>