[R] change file name from file0.1_data.RData to file1_data.Rdata

Rui Barradas ruipbarradas at sapo.pt
Fri Jul 20 01:02:01 CEST 2012


Follow this example.

# First see the regular expression
# at work without changing any disk file
x <- c("file0.1_data.RData", "file0.2_data.RData")
sub("^file0\\.", "file", x)

# Now change them
from.files <- list.files(pattern = "^file0\\.._data.Rdata$")
to.files <- sub("^file0\\.", "file", from.files)
file.rename(from=from.files, to=to.files)

Hope this helps,

Rui Barradas

Em 19-07-2012 23:14, Soyeon Kim escreveu:
> Dear All,
> I want to change file names.
> I have  file0.1_data.RData  (I have several files whose names are
> file0.x_data.Rdata)
> I want to rename it to file1_data.RData
> How can I do it?
> Thank you for saving my time!
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list