These functions provide the "file" version of gsub(), i.e.,
they perform searching and replacement in files via gsub().
gsub_file(file, ..., rw_error = TRUE)
gsub_files(files, ...)
gsub_dir(..., dir = ".", recursive = TRUE, ext = NULL, mimetype = ".*")
gsub_ext(ext, ..., dir = ".", recursive = TRUE)Path of a single file.
For gsub_file(), arguments passed to gsub(). For
other functions, arguments passed to gsub_file(). Note that the
argument x of gsub() is the content of the file.
Whether to signal an error if the file cannot be read or
written. If FALSE, the file will be ignored (with a warning).
A vector of file paths.
Path to a directory (all files under this directory will be replaced).
Whether to find files recursively under a directory.
A vector of filename extensions (without the leading periods).
A regular expression to filter files based on their MIME
types, e.g., '^text/' for plain text files.
These functions perform in-place replacement, i.e., the files will be overwritten. Make sure you backup your files in advance, or use version control!