The FINDFILE function returns a string array containing the names of all files matching File_Specification .

All matched filenames are returned in a string array, one file name per array element. If no files exist with names matching the File_Specification a null scalar string is returned instead of a string array. Except for VMS, described below, FINDFILE returns the full path only if the path itself is specified in File_Specification . See the "Examples" section below for details.

Calling Sequence

Result = FINDFILE( File_Specification )



A scalar string used to find files. The string can contain any valid command-interpreter wildcard characters. If File_Specification contains path information, that path information is included in the returned value. If File_Specification is omitted, the names of all files in the current directory are returned.



A named variable into which the number of files found is placed. If no files are found, a value of 0 is returned.


To print the file names of all the Unix files with "dat" extensions in the current directory, use the command:


To print the full path names of all .pro files in the IDL lib directory that begin with the letter "x", use the command:

PRINT, FINDFILE('/usr/local/rsi/idl/lib/x*.pro')

To print the path names of all .pro files in the profiles subdirectory of the current directory (a relative path), use the command:

PRINT, FINDFILE('profiles/*.pro')

Note that the values returned are (like the File_Specification ) relative path names. Use caution when comparing values against this type of relative path specification.

See Also