EVOLUTION-MANAGER
Edit File: basename.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: Manipulate File Paths</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 basename {base}"><tr><td>basename {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Manipulate File Paths</h2> <h3>Description</h3> <p><code>basename</code> removes all of the path up to and including the last path separator (if any). </p> <p><code>dirname</code> returns the part of the <code>path</code> up to but excluding the last path separator, or <code>"."</code> if there is no path separator. </p> <h3>Usage</h3> <pre> basename(path) dirname(path) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>path</code></td> <td> <p>character vector, containing path names.</p> </td></tr> </table> <h3>Details</h3> <p>For <code>dirname</code> <a href="path.expand.html">tilde expansion</a> of the path is done. </p> <p>Trailing path separators are removed before dissecting the path, and for <code>dirname</code> any trailing file separators are removed from the result. </p> <h3>Value</h3> <p>A character vector of the same length as <code>path</code>. A zero-length input will give a zero-length output with no error. </p> <p>Paths not containing any separators are taken to be in the current directory, so <code>dirname</code> returns <code>"."</code>. </p> <p>If an element of <code>path</code> is <code><a href="NA.html">NA</a></code>, so is the result. </p> <p><code>""</code> is not a valid pathname, but is returned unchanged. </p> <h3>Behaviour on Windows</h3> <p>On Windows this will accept either <code>\</code> or <code>/</code> as the path separator, but <code>dirname</code> will return a path using <code>/</code> (except if on a network share, when the leading <code>\\</code> will be preserved). Expect these only to be able to handle complete paths, and not for example just a network share or a drive. </p> <p>UTF-8-encoded path names not valid in the current locale can be used. </p> <h3>Note</h3> <p>These are not wrappers for the POSIX system functions of the same names: in particular they do <strong>not</strong> have the special handling of the path <code>"/"</code> and of returning <code>"."</code> for empty strings. </p> <h3>See Also</h3> <p><code><a href="file.path.html">file.path</a></code>, <code><a href="path.expand.html">path.expand</a></code>. </p> <h3>Examples</h3> <pre> basename(file.path("","p1","p2","p3", c("file1", "file2"))) dirname(file.path("","p1","p2","p3","filename")) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>