file_extension()
Get the extension of a file.
file_name()
Get the name of a file.
file_dir()
Get or directory of a file
manipulate_files()
Manipulate files in a directory with options to rename
(insert prefix or suffix) and save the new files to the same or other provided
directory.
pliman_indexes()
Get the indexes available in pliman.
pliman_indexes_eq()
Get the equation of the indexes available
in pliman.
file_extension(file)file_name(file)
file_dir(file)
manipulate_files(
pattern,
dir = NULL,
prefix = NULL,
name = NULL,
suffix = NULL,
extension = NULL,
sep = "",
save_to = NULL,
overwrite = FALSE,
remove_original = FALSE,
verbose = TRUE
)
pliman_indexes()
pliman_indexes_eq()
file_extension()
, file_name()
, and file_dir()
return a character
string.
manipulate_files()
No return value. If verbose == TRUE
, a message is
printed indicating which operation succeeded (or not) for each of the files
attempted.
The file name.
A file name pattern.
The working directory containing the files to be manipulated. Defaults to the current working directory.
A prefix or suffix to be added in the new file names.
Defaults to NULL
(no prefix or suffix).
The name of the new files. Defaults to NULL
(original names).
name
can be either a single value or a character vector of the same
length as the number of files manipulated. If one value is informed, a
sequential vector of names will be created as "name
_1", "name
_2", and
so on.
The new extension of the file. If not declared (default), the original extensions will be used.
An optional separator. Defaults to ""
.
The directory to save the new files. Defaults to the current
working directory. If the file name of a file is not changed, nothing will
occur. If save_to
refers to a subfolder in the current working directory,
the files will be saved to the given folder. In case of the folder doesn't
exist, it will be created. By default, the files will not be overwritten.
Set overwrite = TRUE
to overwrite the files.
Overwrite the files? Defaults to FALSE
.
Remove original files after manipulation? defaults to
FALSE
. If TRUE
the files in pattern
will be removed.
If FALSE
, the code is run silently.
# \donttest{
library(pliman)
# get file name, directory and extension
file <- "E:/my_folder/my_subfolder/image1.png"
file_dir(file)
file_name(file)
file_extension(file)
# manipulate files
dir <- tempdir()
list.files(dir)
file.create(paste0(dir, "/test.txt"))
list.files(dir)
manipulate_files("test",
dir = paste0(dir, "\\"),
prefix = "chang_",
save_to = paste0(dir, "\\"),
overwrite = TRUE)
list.files(dir)
# }
Run the code above in your browser using DataLab