Renames every file in a folder by replacing text in the file name, and
optionally adding text to the start or end of the name. Give either a single
pattern p and replacement r, or a table of several replacements in pr.
Arguments
- datafolder
Folder containing the files to rename. If left as
NULL, you will be asked to choose a folder.- p
Text to search for in each file name (literal match). Default is a single space.
- r
Text to replace
pwith. Default is "" (i.e. deletep).- suffix
Text to add to the end of each file name (after the file extension).
- prefix
Text to add to the start of each file name.
- pr
A data.table (or data.frame) with columns
pandr, one row for each replacement to make. If given,pandrare ignored.
Details
With the default arguments it simply removes all spaces from the file names.
pis matched as a literal string (not a regular expression), and every occurrence in the name is replaced.This function renames files in place, so there is no undo. Try it on a copy of your folder first.
If a file would be renamed to a name that already exists, it is left alone and a warning is given.