The input parameters are:
dirlist
dir the full path of the directory to be listed
ext the extension of the files to appear in the
listing
Example:
A directory called "frames" contains a sequence of
TIFF files. Assume it is located at
"/Users/Documents/frames"
To list only the "tif" files in this directory the
dirlist procedure might be used by another Tcl
script as follows.
source /Users/Documents/TCL/dirlist.tcl
# print the directory listing to the console
set files [dirlist /Users/Documents/frames .tif]
puts "$files"
The output would look like this,
/Users/Documents/frames/untitled_001.tif
/Users/Documents/frames/untitled_002.tif
etc...
Under Windows the script would be invoked as follows. In particular
notice the use of the forward slash even though under Windows we would
normally use a back slash as a separator when specifying a path.
source H:tcl/dirlist.tcl
set files [dirlist H:/frames .tif]
puts "$files"
Note the use of the source command to "point" the
Tcl interpreter at the directory containing
the listfiles.tcl script.
|