Skip to contents

Base name without the file extension

Usage

basenameSansExt(path)

Arguments

path

character. File path(s). This function is vectorized and supports multiple files.

Value

character. Character vector of same length as path input, with file extension removed. Returns NA if no extension is detected.

Note

This function intentionally doesn't check whether a file exists.

Updated 2019-10-22.

Examples

path <- c("dir/foo.txt", "bar.tar.gz", "DESCRIPTION")
basenameSansExt(path)
#> [1] "foo"         "bar"         "DESCRIPTION"