Add letters to folder name

How can I add a text to a folder using R? For example, I want to add "_2015" to a folder name called (rain) to be rain_2015. Note that I want to change the folder name which has files in it.
Thanks

file.rename() should do it.

suffix <- "_2015"
oldname <-  "rain"
newname <- paste0(oldname, suffix)
file.rename(oldname, newname)

1 Like

Thank you so much. It is very helpful

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.