Extract file name, extension and basename ofrom a path.é
getExtension(x, sep = .Platform$file.sep) getFilename(x, sep = .Platform$file.sep) getName(x, sep = .Platform$file.sep) getBasename(x, sep = .Platform$file.sep) getLocation(x, sep = .Platform$file.sep) getDetails(x, sep = .Platform$file.sep)
x | a character string. Note that |
---|---|
sep | file separator, default used the platform-specific file separator see |
Extract the file extension a character string (e.g. a path).
For more functionalities, have a look at package fs.
getFilename
: Extract the file name from a character string, that is the base name and the file extension
getName
: Extract the name of a file or a directory from a character string.
getBasename
: Extract the base name of a file from a character string.
getLocation
: Extract the location of the parent folfder from a character string.
getDetails
: Return a data frame with basic information for all elements of a vector of paths.
getExtension("path1/path2/foo.R")#> [1] "R"getFilename("path1/path2/foo.R")#> [1] "foo.R"getBasename("path1/path2/foo.R")#> [1] "foo"getLocation("path1/path2/foo.R")#> [1] "path1/path2"getDetails("path1/path2/foo.R")#> Name Location Basename Extension Directory #> 1 foo.R path1/path2 foo R FALSE#> Name Location Basename Extension Directory #> 1 adjustStrings.html . adjustStrings html FALSE #> 2 aggregateCol.html . aggregateCol html FALSE #> 3 applyString.html . applyString html FALSE #> 4 assignClass2df.html . assignClass2df html FALSE #> 5 assignIds.html . assignIds html FALSE #> 6 categorize.html . categorize html FALSE #> 7 dfTemplate.html . dfTemplate html FALSE #> 8 duplicateRow.html . duplicateRow html FALSE #> 9 findThem.html . findThem html FALSE #> 10 gaussianShape-1.png . gaussianShape-1 png FALSE #> 11 gaussianShape.html . gaussianShape html FALSE #> 12 getDigits.html . getDigits html FALSE #> 13 index.html . index html FALSE #> 14 Rplot001.png . Rplot001 png FALSEgetExtension("foo.R")#> [1] "R"getBasename("foo.R")#> [1] "foo"