title: How do I copy file and folder structure using xcopy from a text file?
body: <p>I have a text file containing a list of files and folders.  What I want to do is use xcopy to replicate what is written in the text file.  My text file looks like this:</p>
  
  <pre><code>"C:\FOLDER"  
  "C:\FOLDER\FILE1.TXT"
  "C:\FOLDER\FILE2.TXT"
  "C:\FOLDER\FOLDER2"
  "C:\FOLDER\FOLDER2\FILE3.TXT"
  </code></pre>
  
  <p>For a given output directory <code>"C:\OUTPUT"</code> I would like to replicate the entire structure, so:</p>
  
  <pre><code>"C:\OUTPUT\FOLDER"  
  "C:\OUTPUT\FOLDER\FILE1.TXT"
  "C:\OUTPUT\FOLDER\FILE2.TXT"
  "C:\OUTPUT\FOLDER\FOLDER2"
  "C:\OUTPUT\FOLDER\FOLDER2\FILE3.TXT"
  </code></pre>
  
  <p>How can I accomplish this?  So far I have written a for loop that reads in each line of the file, but it copies all files if the line is a folder.  What I want to do is only copy and create the files and folders that are mentioned in the text file.</p>
  
  <pre><code>@echo off
  for /f "delims=] tokens=1*" %%a in (textfile.txt) do (
     XCOPY /S /E %%a "C:\OUTPUT"
  )
  </code></pre>
  
  <p>Am I on the right track?</p>
  
  <p>Thank you and best regards,</p>
  
  <p>Andrew</p>