Find file name from full file path Find file name from full file path r r

Find file name from full file path


Use

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


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)