\HeaderA{list.files}{List the Files in a Directory/Folder}{list.files}
\aliasA{dir}{list.files}{dir}
\keyword{file}{list.files}
\begin{Description}\relax
These functions produce a character vector of the names of files
in the named directory.
\end{Description}
\begin{Usage}
\begin{verbatim}
list.files(path = ".", pattern = NULL, all.files = FALSE,
           full.names = FALSE, recursive = FALSE)
       dir(path = ".", pattern = NULL, all.files = FALSE,
           full.names = FALSE, recursive = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{path}] a character vector of full path names; the default
corresponds to the working directory \code{\LinkA{getwd}{getwd}()}.
\item[\code{pattern}] an optional \LinkA{regular expression}{regular expression}.  Only file names
which match the regular expression will be returned.
\item[\code{all.files}] a logical value. If \code{FALSE}, only the
names of visible files are returned.  If \code{TRUE},
all file names will be returned.
\item[\code{full.names}] a logical value.  If \code{TRUE}, the directory
path is prepended to the file names.  If \code{FALSE}, only
the file names are returned.
\item[\code{recursive}] logical. Should the listing recurse into directories?
\end{ldescription}
\end{Arguments}
\begin{Value}
A character vector containing the names of the files in the
specified directories, or \code{""} if there were no files. If a
path does not exist or is not a directory or is unreadable it
is skipped, with a warning.

The files are sorted in alphabetical order, on the full path
if \code{full.names = TRUE}.
\end{Value}
\begin{Note}\relax
File naming conventions are very platform dependent.

\code{recursive = TRUE} is not supported on all platforms, and may be
ignored, with a warning.
\end{Note}
\begin{Author}\relax
Ross Ihaka, Brian Ripley
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{file.info}{file.info}}, \code{\LinkA{file.access}{file.access}}
and \code{\LinkA{files}{files}} for many more file handling functions and 
\code{\LinkA{file.choose}{file.choose}} 
for interactive selection.

\code{\LinkA{glob2rx}{glob2rx}} to convert wildcards (as used by system file
commands and shells) to regular expressions.

\code{\LinkA{Sys.glob}{Sys.glob}} for wildcard expansion on file paths.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
list.files(R.home())
## Only files starting with a-l or r
dir("../..", pattern = "^[a-lr]",full.names=TRUE)
\end{ExampleCode}
\end{Examples}

