title: How to replicate a directory structure using xcopy in windows
body: <p>I have a text file containing a list of folders.My text file looks like this:</p>
  
  <pre>
  "D:\old\FOLDER1"  
  "D:\old\FOLDER2"  
  "D:\old\FOLDER3"  
  "D:\old\FOLDER4"  
  "D:\old\FOLDER5"  
  </pre>
  
  <p>all these folders have subfolders and files under it</p>
  
  <p>what I want to do is use xcopy to copy <code>FOLDER1</code>, <code>FOLDER2</code> , <code>FOLDER3</code> <code>FOLDER4</code> and <code>FOLDER5</code> replicate folders ,replicating the structure of those folders
  so in output , I want to get </p>
  
  <pre>
  D:\output\bkup\FOLDER1\............Including all subfolders and files D:\output\bkup\FOLDER2\............Including all subfolders and files D:\output\bkup\FOLDER3\.......... Including all subfolders and files 
  D:\output\bkup\FOLDER4\............Including all subfolders and files 
  D:\output\bkup\FOLDER5\............ Including all subfolders and files 
  </pre>
  
  <p>I have written  below script which works fine for one folder </p>
  
  <pre><code>set sourceFolder="D:\old\FOLDER5"
  set destinationFolder=%sourceFolder:~7,-1%
  echo %destinationFolder%
  xcopy /s /e /i /h /r /y %sourceFolder%  "D:\output\bkup%destinationFolder%"
  </code></pre>
  
  <p>but since # of directories to copy is 100+ ,I like to use a for loop or pass the list of directories to copy in a text file , that's what I don't know how to handle it.</p>
  
  <p>please help me ,I'm not expert in batch file writing.</p>