Manipulate File Paths

DESCRIPTION:

The basename function removes all of the given path up to the last path separator. It can also remove a specified filename suffix. The dirname function returns the part of the given path up to, but not including, the last path separator. It returns "." if there is no path separator in the path.

USAGE:

basename(path, suffix)
dirname(path)

REQUIRED ARGUMENTS:

path
a character vector, typically specifying paths to files.

OPTIONAL ARGUMENTS:

suffix
a single character string giving the suffix to be removed from the final file named in path.

VALUE:

a character vector the same length as path, containing either the final filenames (basename) or the path up the final filenames (dirname).

DETAILS:

Trailing file separators are always removed before operating on the path and trailing file separators are not returned by dirname..

These functions are similiar to the command line utilities by the same name in Unix/Linux.

SEE ALSO:

.

EXAMPLES:

dirname("/users/bob/data/salmon.csv")
basename("/homes/larry/help/lreg.Rd", suffix=".Rd")