Base name without the file extension

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.

See also

Examples

basenameSansExt(c("dir/foo.txt", "dir/bar.tar.gz", "dir/"))
#> [1] "foo" "bar" NA