makeFilenames: [!+] Convert string into Windows compatible filename

View source: R/makeFilenames.R

makeFilenamesR Documentation

[!+] Convert string into Windows compatible filename

Description

This is a function (make.filenames) from https://github.com/GegznaV/spMisc repository. This function replaces special symbols (\" / : * ? < > |) in a string s with replacement (by default it is underscore _). After replacement the string can be used as a file name in Windows.

Usage

makeFilenames(s, replacement = "_", allow.space = TRUE)

Arguments

s

A string.

replacement

A symbol to replce unallowed symbols with. replacement must be an allowed symbol.

allow.space

Logical. If FALSE, space will be repalaced with replacement. Default is TRUE.

Value

A string without special symbols.

Examples

 s <- '\\ / : * ? " < > |'
 makeFilenames(s)
 #> "_ _ _ _ _ _ _ _ _"

 makeFilenames(s, allow.space = FALSE)
 #> "_________________"


 s2 <- "/Hello?"
 makeFilenames(s2)
 #> "_Hello_"

 makeFilenames(s2, replacement = "-")
 #> "-Hello-"


paodan/funcTools documentation built on April 1, 2024, 12:01 a.m.