Find file name from full file path

The tidyverse equivalent lives in the fs package. {fs} makes use of libuv under the hood.

library("fs")

path_file("/some/path/to/file.xyz")
#> [1] "file.xyz"

path_dir("/some/path/to/file.xyz")
#> [1] "/some/path/to"

Created on 2020-02-19 by the reprex package (v0.3.0)


Use

basename("C:/some_dir/a.ext")
# [1] "a.ext"
dirname("C:/some_dir/a.ext")
# [1] "C:/some_dir"

@Honeybear. The function that removes the extension from the filename you could use is the function from the {tools} R package

tools::file_path_sans_ext("ABCD.csv")
## [1] "ABCD"

See this post in SO

Tags:

File

Path

R