file_ext: Manipulate filename extensions

Description Usage Arguments Details Value Examples

View source: R/paths.R

Description

Functions to obtain (file_ext()), remove (sans_ext()), and change (with_ext()) extensions in filenames.

Usage

1
2
3
4
5
file_ext(x)

sans_ext(x)

with_ext(x, ext)

Arguments

x

A character of file paths.

ext

A vector of new extensions.

Details

file_ext() is a wrapper of tools::file_ext(). sans_ext() is a wrapper of tools::file_path_sans_ext().

Value

A character vector of the same length as x.

Examples

1
2
3
4
5
6
7
library(xfun)
p = c("abc.doc", "def123.tex", "path/to/foo.Rmd")
file_ext(p)
sans_ext(p)
with_ext(p, ".txt")
with_ext(p, c(".ppt", ".sty", ".Rnw"))
with_ext(p, "html")

yihui/xfun documentation built on Oct. 25, 2018, 11:44 p.m.