Is there a way to extract the file name from the file full path (part of a file path) without the hassle of manipulating string?
是否有一种方法可以从文件完整路径(文件路径的一部分)中提取文件名而不需要处理字符串?
The equivalent in Java would be:
在Java中相当于:
File f = new File ("C:/some_dir/a")
f.getName() //output a
f.getFullAbsolutePath() //output c:/some_dir/a
1 个解决方案
#1
204
Use
使用
basename("C:/some_dir/a.ext")
# [1] "a.ext"
dirname("C:/some_dir/a.ext")
# [1] "C:/some_dir"
#1
204
Use
使用
basename("C:/some_dir/a.ext")
# [1] "a.ext"
dirname("C:/some_dir/a.ext")
# [1] "C:/some_dir"