get_ext: Filename extension utilities

Description Usage Arguments Value See Also Examples

View source: R/ext.R

Description

Replaces, adds or removes (rm) extensions from filenames or test whether filename has an extension or is a filename with a particular extension. Functions are primarily wrappers on the tools package functions file_ext and file_path_sans_ext.

Usage

1
2
3
4
5
6
get_ext(x)
has_ext(x)
is_ext(x, ext)
rm_ext(x)
replace_ext(x, ext)
add_ext(x, ext)

Arguments

x

a character vector of the filenames.

ext

a character scalar of the extension with or without a leading point.

Value

A character vector of the extensions or modified filenames or a logical vector indicating whether a filename has an extension or is a particular extension.

See Also

file_ext and file_path_sans_ext

Examples

1
2
3
4
5
6
7
8
x <- c('file', 'file.txt', 'file.txt.zip')
get_ext(x)
has_ext(x)
is_ext(x, 'txt')
is_ext(x, '.txt')
rm_ext(x)
replace_ext(x, 'md')
add_ext(x, 'md')

poissonconsulting/tulip documentation built on Feb. 18, 2021, 11:18 p.m.