title: How can I copy files from folders and subfolders to another folder in R?
body: <p>I would like to copy <strong>files only</strong> from 1 root folder that has 100's of folders and subfolders. I do not want to copy the folders. I just want to copy all the files (*.iso, *.txt, *.docx, *.pdf etc.) there are in these folders to another folder. </p>
  
  <p>My code:</p>
  
  <pre><code>setwd("/Users/RLearner/Desktop/RDMS")
  
  if (file.exists(list.files(path=".",recursive=TRUE)))
    file.copy(from=".", to="/Users/RLearner/Desktop/Test", recursive=TRUE)
  </code></pre>
  
  <p>But this code is copying the root folder as it is into my desired <code>Test</code> folder. I just want to copy the files that these folders have?</p>