Hello,
I would like to rename multiple files in a directory. Filenames are read using:

lfile <- list.files(pattern="rcp45_Daily_") 
files <-  paste(paste(getwd(),lfile,sep="/"), list.files(lfile),sep="/")# getwd 
of these files 

dput(lfile) 
c("rcp45_Daily_Sim001.dat", "rcp45_Daily_Sim002.dat") 


- How can I rename these files (200 in number) using something like:
  file.rename(lfile, paste0("rcp45_Daily_Sim", 1:200))?The new filenames should 
be rcp45_Daily_Sim001, rcp45_Daily_Sim002, ..., rcp45_Daily_Sim200.

- I would like to write the new file names to the directory.

The data files contain huge amounts of data and should not be read into R. Only 
the file names should change.

Many thanks for your helpful answers.
Asong.

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to