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 commaAnd.html . commaAnd html FALSE #> 8 dfTemplate.html . dfTemplate html FALSE #> 9 duplicateRow.html . duplicateRow html FALSE #> 10 findThem.html . findThem html FALSE #> 11 gaussianShape-1.png . gaussianShape-1 png FALSE #> 12 gaussianShape.html . gaussianShape html FALSE #> 13 getDigits.html . getDigits html FALSE #> 14 getExtension.html . getExtension html FALSE #> 15 index.html . index html FALSE #> 16 keepWords.html . keepWords html FALSE #> 17 logistic.html . logistic html FALSE #> 18 loremIpsum.html . loremIpsum html FALSE #> 19 meanAlong.html . meanAlong html FALSE #> 20 msgInfo.html . msgInfo html FALSE #> 21 multiMatch.html . multiMatch html FALSE #> 22 packagesUsed.html . packagesUsed html FALSE #> 23 readYamlHeader.html . readYamlHeader html FALSE #> 24 rename.html . rename html FALSE #> 25 Rplot001.png . Rplot001 png FALSE #> 26 scaleWithin.html . scaleWithin html FALSE #> 27 seqRg.html . seqRg html FALSE #> 28 setColClass.html . setColClass html FALSE #> 29 signifSymbols.html . signifSymbols html FALSE #> 30 squaretize.html . squaretize html FALSE #> 31 stopwatch.html . stopwatch html FALSE #> 32 tblDown.html . tblDown html FALSE #> 33 whichIs.html . whichIs html FALSEgetExtension("foo.R")#> [1] "R"getBasename("foo.R")#> [1] "foo"