Learn R Programming

SciencesPo (version 0.11.21)

rename.files: Rename files recursively

Description

Rename files in a directory with the same regex procedure.

Usage

rename.files(dir, pattern, replacement)

Arguments

dir
Path to directory for which you want to change the file names.
pattern
Pattern in file name to replace.
replacement
Text to replace pattern with.

Value

  • Prints Done! to console when done; look at files in directory dir for changes.

encoding

UTF-8

Examples

Run this code
# For example, a file name may have hyphen "-", 
# and you can replace them with underline "_".
rename.files("~/Desktop/mydata", "-", "_")

Run the code above in your browser using DataLab