myfilepath <- "F:/paper2/climateExposure/wjj_mec/second/paths/"setwd(myfilepath)alltypefiles = dir(myfilepath)newname = gsub(pattern = 'paths.',replacement = 'paths_',x = alltypefiles)file.rename(alltypefiles,newname)