title: how to copy x days old files from folders and subfolders to new location while maintaining current folder structure in windows?
body: <p>I have 3 Application servers and 3 Web servers. Each of them generates logs on their own machine.
  The log file path is shared on a separate machine (all are Windows Machines).</p>
  
  <p>Logs location for App servers:</p>
  
  <pre><code> Source_App1=\\192.168.1.x\d$\Temp\ErrorLog 
   Source_App2=\\192.168.2.x\d$\Temp\ErrorLog 
   Source_App3=\\192.168.3.x\d$\Temp\ErrorLog
  </code></pre>
  
  <p>Under above each location there are 4 folders, say <code>folder1</code>, <code>folder2</code>, <code>folder3</code>, <code>folder4</code>. this is where all log files of Application server is created.</p>
  
  <p>Logs location for Web servers:</p>
  
  <pre><code>Source_Web1=\\192.168.4.x\d$\Temp\ErrorLog
  Source_Web2=\\192.168.5.x\d$\Temp\ErrorLog
  Source_Web3=\\192.168.6.x\d$\Temp\ErrorLog
  </code></pre>
  
  <p>Under above each location there are 4 folders, say <code>folder1</code>, <code>folder2</code>, <code>folder3</code>, <code>folder4</code>. This is where all log files of Web server is created.</p>
  
  <p>I want to move <code>X</code> days old logs files from each of the location to a single separate location:</p>
  
  <pre><code>Destination=\\192.168.7.x\D$\backups\Prod App &amp; Web Error Logs Backup\
  </code></pre>
  
  <p>Under above destination location it should create two folders like <code>App</code> and <code>Web</code>.</p>
  
  <p>Now I want to copy all <code>App1</code>, <code>App2</code>, <code>App3</code> folders to destination <code>App</code> folder.</p>
  
  <p>And <code>Web1</code>, <code>Web2</code>, <code>Web3</code> to destination <code>Web</code> folder.</p>
  
  <p>But the directory structure should be created automatically.</p>
  
  <p>I tried:</p>
  
  <pre><code>for /D %i in ("%Source_App1%*") do if not exist "%Destination%\App\App1\%i" mkdir "%Destination%\App\App1\%i"
  </code></pre>
  
  <p>But it is not working.</p>
  
  <p>Can you please help me in this?</p>