title: How to unrar all RAR files in a folder to a specific target folder?
body: <p>I have a file batch to unrar all RAR files in a folder into a subfolder. </p>
  
  <pre><code>C:\test\sub-folder\file.rar -&gt; C:\test\sub-folder\fileunrar
  </code></pre>
  
  <p>But when I run it, the file is unpacked to the base folder:</p>
  
  <pre><code>C:\test\sub-folder\file.rar -&gt; C:\test\fileunrar
  </code></pre>
  
  <p>This is the batch file I'm currently using:</p>
  
  <pre><code>@ECHO OFF
  cd C:\test
  SET PATH=C:;C:\Program Files\WinRAR;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;%PATH%
  FOR /f "delims=" %%d IN ('DIR /B') DO unRaR x -y -r -o- *.rar
  EXIT
  </code></pre>
  
  <p>Why are the RAR archives extracted to base folder?</p>