title: File extension renaming in R
body: <p>I am just trying to change the filename extensions to .doc. I'm trying the code below but it does not work. How come? I'm using instructions from <a href="https://www.r-bloggers.com/programatically-rename-files-or-do-other-stuff-to-them-in-r/" rel="noreferrer">here</a></p>
  
  <pre><code>startingDir&lt;-"C:/Data/SCRIPTS/R/TextMining/myData"
  
  filez&lt;-list.files(startingDir)
  
  sapply(filez,FUN=function(eachPath){
    file.rename(from=eachPath,to=sub(pattern =".LOG",replacement=".DOC",eachPath))
  })
  </code></pre>
  
  <p>The output I get is:</p>
  
  <pre><code>DD17-01.LOG DD17-02.LOG DD17-03.LOG  DD17-4.LOG  DD17-5.LOG DD37-01.LOG DD37-02.LOG DD39-01.LOG DD39-02.LOG DD39-03.LOG 
        FALSE       FALSE       FALSE       FALSE       FALSE       FALSE       FALSE       FALSE       FALSE       FALSE 
  </code></pre>