EVOLUTION-MANAGER
Edit File: list.files.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: List the Files in a Directory/Folder</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for list.files {base}"><tr><td>list.files {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>List the Files in a Directory/Folder</h2> <h3>Description</h3> <p>These functions produce a character vector of the names of files or directories in the named directory. </p> <h3>Usage</h3> <pre> list.files(path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE) dir(path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE) list.dirs(path = ".", full.names = TRUE, recursive = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>path</code></td> <td> <p>a character vector of full path names; the default corresponds to the working directory, <code><a href="getwd.html">getwd</a>()</code>. Tilde expansion (see <code><a href="path.expand.html">path.expand</a></code>) is performed. Missing values will be ignored.</p> </td></tr> <tr valign="top"><td><code>pattern</code></td> <td> <p>an optional <a href="regex.html">regular expression</a>. Only file names which match the regular expression will be returned.</p> </td></tr> <tr valign="top"><td><code>all.files</code></td> <td> <p>a logical value. If <code>FALSE</code>, only the names of visible files are returned. If <code>TRUE</code>, all file names will be returned.</p> </td></tr> <tr valign="top"><td><code>full.names</code></td> <td> <p>a logical value. If <code>TRUE</code>, the directory path is prepended to the file names to give a relative file path. If <code>FALSE</code>, the file names (rather than paths) are returned.</p> </td></tr> <tr valign="top"><td><code>recursive</code></td> <td> <p>logical. Should the listing recurse into directories?</p> </td></tr> <tr valign="top"><td><code>ignore.case</code></td> <td> <p>logical. Should pattern-matching be case-insensitive?</p> </td></tr> <tr valign="top"><td><code>include.dirs</code></td> <td> <p>logical. Should subdirectory names be included in recursive listings? (They always are in non-recursive ones).</p> </td></tr> <tr valign="top"><td><code>no..</code></td> <td> <p>logical. Should both <code>"."</code> and <code>".."</code> be excluded also from non-recursive listings?</p> </td></tr> </table> <h3>Value</h3> <p>A character vector containing the names of the files in the specified directories (empty 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. </p> <p>The files are sorted in alphabetical order, on the full path if <code>full.names = TRUE</code>. </p> <p><code>list.dirs</code> implicitly has <code>all.files = TRUE</code>, and if <code>recursive = TRUE</code>, the answer includes <code>path</code> itself (provided it is a readable directory). </p> <h3>Note</h3> <p>File naming conventions are platform dependent. The pattern matching works with the case of file names as returned by the OS. </p> <p>On a POSIX filesystem recursive listings will follow symbolic links to directories. </p> <h3>Author(s)</h3> <p>Ross Ihaka, Brian Ripley</p> <h3>See Also</h3> <p><code><a href="file.info.html">file.info</a></code>, <code><a href="file.access.html">file.access</a></code> and <code><a href="files.html">files</a></code> for many more file handling functions and <code><a href="file.choose.html">file.choose</a></code> for interactive selection. </p> <p><code><a href="../../utils/html/glob2rx.html">glob2rx</a></code> to convert wildcards (as used by system file commands and shells) to regular expressions. </p> <p><code><a href="Sys.glob.html">Sys.glob</a></code> for wildcard expansion on file paths. </p> <h3>Examples</h3> <pre> list.files(R.home()) ## Only files starting with a-l or r ## Note that a-l is locale-dependent, but using case-insensitive ## matching makes it unambiguous in English locales dir("../..", pattern = "^[a-lr]", full.names = TRUE, ignore.case = TRUE) list.dirs(R.home("doc")) list.dirs(R.home("doc"), full.names = FALSE) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>