title: rename multiple files in a folder using R
body: <p>I have a folder which contains several files named by the date the data was measured. For example: "07182014.csv","07192014.csv"...</p>
  
  <p>Since I have multiple stations for the measurements, I would like to add the station number before each file name for distinguish purposes. For example, the file "07182014.csv" will become "N1_07182014.csv".</p>
  
  <p>I'm new to R, and most of the time I search the web for solutions to my data analysis problem.</p>
  
  <p>Can someone help me revise the code I'm having below so I can properly rename all files in the folder? Or if any other better solution can be provided, that will be helpful!</p>
  
  <pre><code>setwd("C:\\data")
  files &lt;- list.files() 
  sapply(files,FUN=function(eachPath){ 
  file.rename(from=eachPath,to=sub(pattern="[$.csv]", paste0("N0_"),eachPath)) 
  }) 
  </code></pre>
  
  <p>Thanks a lot！</p>