Perform Bulk Find-and-Replace on Multiple Files Using stringr
Source:R/ngr_str_replace_in_files.R
ngr_str_replace_in_files.RdThis function explicitly reads the content of files, performs find-and-replace
operations using stringr, and writes the updated content back to the files.
It handles word boundaries, trailing punctuation, and allows for specific symbols
like @ to precede the text to be replaced.
Arguments
- text_current
character A string representing the text to be replaced in filenames.
- text_replace
character A string representing the new text to replace the current text in filenames.
- files
character A vector of file paths to perform find-and-replace operations on.
- ask
logical Whether to prompt the user for confirmation before renaming. Default is
TRUE.
Value
logical Invisibly returns a logical vector indicating success for each file.