title: Rename several files in windows folder with R
body: <p>I have a folder in windows with 1000 files with <em>".dts"</em> format like <strong>20170217.dts</strong> . I want to rename all the file's name and change the year to 2019 , like <strong>20190217.dts</strong>. My aim is properly rename all files in the folder to be able to open them in another software. I tried this:</p>
  
  <pre><code># define file path
  
  filepath &lt;- "C:/my file path/"
  
  myfile_dts_2019 &lt;- list.files(path = filepath , pattern =".dts")
  
  # print
  myfile_dts_2019
  
  [1] "20172303.dts" "20172403.dts"
  
  
  # replace 2017 with 2019
  newfiles &lt;- stringr::str_replace(myfile_dts_2019,"2017","2019")
  
  newfiles
  
  [1] "20192303.dts" "20192403.dts"
  
  # try to rename on the folder
  
  file.rename(myfile_dts_2019, newfiles)
  
  [1] TRUE TRUE
  </code></pre>
  
  <p>My script seems working in R, however the original files in the folder still have a name start with <em>2017</em>. I am wondering how can I rename them inside the windows folder as well.</p>