title: Copy Multiple Directories into One Directory Keeping the root folder using Robocopy
body: <p>I am trying to create a batch script to copy multiple directories in different locations into one single directory in another location. The problem is that robocopy is copying the internal contents of the root directory and not the root directory itself </p>
  
  <p>So If I have 3 directories in location a being :
  <strong>C:\dir1</strong> , <strong>C:\dir2</strong> , <strong>C:\dir3</strong></p>
  
  <p>and I want to copy them to one single folder onto another location ex:
  <strong>D:\dirBackups</strong></p>
  
  <p>so that the outcome would be <strong>D:\dirBackups\dir1</strong> , <strong>D:\dirBackups\dir2</strong>, <strong>D:\dirBackups/dir3</strong></p>
  
  <p>Currently robocopy is copying the stuff inside <strong>dir1</strong> , <strong>dir2</strong> and <strong>dir3</strong> so I am ending up with the contents of the three directories all into <strong>D:\dirBackups</strong></p>
  
  <p>I am using the following code</p>
  
  <pre><code>for /F "tokens=*" %%A in (%pathsFile%) do (
     robocopy %%A D:\dirBackups /E /COPYALL /XF /SEC /SECFIX /TIMFIX /W:0 /R:1 /REG /XJ /Z /FFT
  )
  </code></pre>
  
  <p><strong><em>%pathsFile%</em></strong> is a text file which contains the directories to be backed up into <strong>D:\dirBackups</strong>, so I am looping through the file and for each line I am triggering the same robocopy Command.</p>
  
  <p>The files are getting copied well but the root directory is never included so it's working like it's expanding all the folders and only copying the inner content of each folder into one location.</p>
  
  <p>Thanks</p>