Learn R Programming

staplr (version 3.2.2)

rename_files: Rename multiple files

Description

Rename multiple files in a directory and write renamed files back to directory

Usage

rename_files(input_directory = NULL, new_names)

Value

A logical vector indicating which files were successfully renamed.

Arguments

input_directory

the path of the input PDF files. The default is set to NULL. IF NULL, it prompt the user to select the folder interactively.

new_names

a vector of names for the output files.

Author

Priyanga Dilini Talagala

References

https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

Examples

Run this code
# \dontshow{
if (requireNamespace("lattice", quietly = TRUE)) {
dir <- tempfile()
dir.create(dir)
for(i in 1:3) {
pdf(file.path(dir, paste("plot", i, ".pdf", sep = "")))
print(lattice::xyplot(iris[,1] ~ iris[,i], data = iris))
dev.off()
}
n <- length(Sys.glob(file.path(dir,"*.pdf")))
rename_files(input_directory = dir, new_names = paste("file",1:n))
}
# }

Run the code above in your browser using DataLab