title: Rename multiple files in serial number in R
body: <p>I am trying to rename files that are placed in one folder and I need this files to rename them in sequential manner. e.g if I have three file with name </p>
  
  <p>a. Mastersheet.xlsx</p>
  
  <p>b. Subfile.xlsx</p>
  
  <p>c. Analysis.xlsx</p>
  
  <p>and rename them into</p>
  
  <p>a. 1.xlsx</p>
  
  <p>b. 2.xlsx</p>
  
  <p>c. 3.xlsx</p>
  
  <pre><code>files &lt;- list.files(folder,pattern = "*.xlsx",full.names = T) 
  
  sapply(files,FUN=function(eachPath){file.rename(from=eachPath,to=sub(pattern="*.xlsx",paste0("*.xlsx",1:34),eachPath))})
  </code></pre>