renameFiles | R Documentation |
rename files
renameFiles(old, new, replacement = "_", checkExtention = TRUE)
old |
the original file names. The path information IS allowed, |
new |
the new file names. Unless on purpose, the path information
should NOT be included, because "/" in the new file names will be replaced
by characters according to |
replacement |
character(s) to replace the illegal characters in the new names. |
checkExtention |
logical, if TRUE (default) check if new names contains a file extension. |
# old file names
tmpFolder = "./tmp"
dir.create(tmpFolder)
file1 = tempfile(pattern = "oldFile", tmpdir = tmpFolder, fileext = ".csv")
file2 = tempfile(pattern = "oldFile", tmpdir = tmpFolder, fileext = ".csv")
write.csv(cars, file = file1)
write.csv(cars, file = file2)
dir(tmpFolder)
# new file names (must not contain the path, i.e. "./tmp/"!)
newNames = sub("./tmp/oldFile", "newFile", c(file1, file2))
renamed = renameFiles(old = c(file1, file2), new = newNames)
renamed
dir(tmpFolder)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.