From my ACAD2002 help:
vl-directory-files [AutoLISP Reference: VLR]
(vl-directory-files [directory pattern directories])
Arguments
directory
A string naming the directory to collect files for; if nil or absent, vl-directory-files uses the current directory.
pattern
A string containing a DOS pattern for the file name; if nil or absent, vl-directory-files assumes "*.*"
directories
An integer that indicates whether the returned list should include directory names. Specify one of the following:
-1 List directories only.
0 List files and directories (the default).
1 List files only.
;;-------------------------------------------------------------------------------------
;; Function to build a list of drawings found in the specified path and subdirectories:
(defun @find_dwgs (path / spec files spaces dirs @dirs)
(cond
((or (/= (type path) 'STR)(= path ""))
(setq path
(strcase
(vl-filename-directory
(findfile
(car (vl-directory-files "" "*.*" 1))
)
)
)
)
)
((wcmatch path ",*/,*\\"))
(1 (setq path (strcat path "\\")))
)
(setq spec "*.dwg")
(setq spaces " ")
(defun @dirs (path / dirs found)
(princ (strcat "\rSearching " path (substr spaces (strlen path))))
(princ)
(and
(setq found (vl-directory-files path spec 1))
(setq found (mapcar (function (lambda (x)(strcat path x))) found))
(setq files (append files found))
)
(and
(setq dirs (vl-directory-files path "*.*" -1))
(setq dirs (vl-remove-if (function (lambda (x)(vl-position x '("." "..")))) dirs)
dirs (mapcar (function (lambda (x)(strcat path x "\\"))) dirs)
)
)
(foreach dir dirs (@dirs dir))
)
(terpri)
(@dirs path)
(reverse files)
)