File extension

fileExt(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-07-30.

See also

Examples

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