title: How can I move the contents of one directory tree into another?
body: <p>I have a directory which contains files and a number of levels of subdirectories:</p>
  
  <pre><code>C:\Source
  </code></pre>
  
  <p>I would like to move the contents of C:\Source into:</p>
  
  <pre><code>C:\Destination
  </code></pre>
  
  <p>Requirements:</p>
  
  <ul>
  <li>All files and all subdirectories
  <em>within</em> C:\SourceData must be moved</li>
  <li>I will be running the command in a
  batch file</li>
  <li>I can't use Powershell or
  any other scripting languages</li>
  </ul>
  
  <p><strong>Attempt 0</strong></p>
  
  <pre><code>XCOPY /E "C:\Source" "C:\Destination"
  </code></pre>
  
  <p>This works perfectly, but it copies instead of moves. I can't copy then delete the source as I'm moving a very large set of files and there isn't enough disk space to have two copies of them at a time.</p>
  
  <p><strong>Attempt 1</strong></p>
  
  <pre><code>MOVE "C:\Source" "C:\Destination"
  </code></pre>
  
  <p>This moves the entire C:\Source directory <em>into</em> C:\Destination so I end up with:</p>
  
  <pre><code>C:\Destination\Source
  </code></pre>
  
  <p><strong>Attempt 2</strong></p>
  
  <p>With some help from <a href="https://stackoverflow.com/questions/210413">this question and accepted answer</a> I came up with: </p>
  
  <pre><code>for /r "C:\Source" %%x in (*) do move "%%x" "C:\Destination"
  </code></pre>
  
  <p>This moves the files within C:\Source but not the subdirectories or their contents. Note that I used %%x instead of %x as I'm using it in a batch file.</p>
  
  <p>Using FOR seems promising but I'm not sure I've used the right syntax? Have I missed something?</p>
  
  <p><strong>Attempt 3</strong></p>
  
  <p>As suggested by Nick D, I tried rename:</p>
  
  <p>RENAME "C:\Source" Destination</p>
  
  <p>For the example scenario I gave this works fine. Unfortunately my real <em>Destination</em> directory is at a different level to the <em>Source</em> directory and this doesn't seem to be supported:</p>
  
  <pre><code>C:\&gt;REN /?
  Renames a file or files.
  
  RENAME [drive:][path]filename1 filename2.
  REN [drive:][path]filename1 filename2.
  
  Note that you cannot specify a new drive or path for your destination file.
  </code></pre>
  
  <p>I get "The syntax of the command is incorrect." errors if I try to specify a more complex destination path, for example:</p>
  
  <pre><code>RENAME "C:\Source" "C:\MyOtherDirectory\Destination"
  RENAME "C:\Source" "MyOtherDirectory\Destination"
  </code></pre>