Rename files and/or directories using a syntactic naming function
Source:R/rename.R
syntacticRename.RdRename files and/or directories using a syntactic naming function
Usage
syntacticRename(
path,
recursive = FALSE,
fun = c("kebabCase", "snakeCase", "camelCase", "upperCamelCase"),
lowerExt = FALSE,
quiet = FALSE,
dryRun = FALSE
)Arguments
- path
character. File and/or directory paths.- recursive
logical(1). Should the function recurse into directories?- fun
character(1). Function name.- lowerExt
logical(1). Should file extensions be lowercased?- quiet
logical(1). Perform command quietly, suppressing messages.- dryRun
logical(1). Return the proposed file path modifications without modification.
Details
Intelligently deals with a case-insensitive file system, if necessary. This is very useful for macOS and Windows.
Our syntactic naming functions can result in changes that only differ in case, which are problematic on case-insensitive mounts, and require movement of the files into a temporary file name before the final rename.
Examples
testdir <- AcidBase::tempdir2()
#> Error in vapply(X = X, FUN = FUN, FUN.VALUE = logical(1L), ..., USE.NAMES = useNames): formal argument "USE.NAMES" matched by multiple actual arguments
from <- file.path(testdir, c("helloWorld.txt", "fooBar.R"))
#> Error: object 'testdir' not found
file.create(from)
#> Error: object 'from' not found
print(basename(from))
#> Error: object 'from' not found
output <- syntacticRename(from)
#> Error: object 'from' not found
print(output)
#> Error: object 'output' not found
AcidBase::unlink2(testdir)
#> Error: object 'testdir' not found