set.file.extension: Determine or modify file name extensions

Description Usage Arguments Value Examples

Description

Function get.file.extension determines the file extension, set.file.extension changes it, and default.file.extension changes it only if it is not already specified.

Usage

1
2
3
4
5
set.file.extension(filename, extension, fsep = .Platform$file.sep)

get.file.extension(filename, fsep = .Platform$file.sep)

default.file.extension(filename, extension, force = FALSE)

Arguments

filename

character vector: file name(s), possibly including paths and extensions; a file name ending with a "." is interpreted as having extension "", while a file name that doesn't contain a "." is interpreted has having no extension.

extension

character string: file extension, without the dot

fsep

character: separator between paths

force

logical argument to default.file.extension: force the file extension to be extension (same result as set.file.extension), or only set it to extension if it has not been specified?

Value

character vector of same length as filename

Examples

1
2
3
4
fnm = c("C:/TEMP.DIR/temp","C:/TEMP.DIR/tmp.txt","tempfile.")
get.file.extension(fnm)
set.file.extension(fnm,extension=".TMP")
default.file.extension(fnm,extension=".TMP")

debangs/RSAGA documentation built on May 15, 2019, 1:53 a.m.