title: extract all rar files in a folder and sub-folder to same folder
body: <p>I found this post for extracting rar files from one folder to same folder name:  <a href="https://stackoverflow.com/questions/45749246/extract-rar-files-to-same-folder-name/45749549#45749549?newreg=722e826eef734393b79abf759244eff9">extract rar files to same folder name</a></p>
  
  <p>I want to extract several rar files in sub-folders to sub-folders of the same name i.e.</p>
  
  <p><code>/folder/sub-folder1/file1.rar --&gt; /folder/sub-folder1/new-folder-same-name-as-sub-folder1/extracted_files.xyz</code></p>
  
  <p><code>/folder/sub-folder2/file2.rar --&gt; /folder/sub-folder2/new-folder-same-name-as-sub-folder2/extracted_files.xyz</code></p>
  
  <p>How do I modify:</p>
  
  <pre><code>#!/bin/bash
  
      for archive in "$(find $loc -name '*.rar')"; do
        destination="${archive%.rar}"
        if [ ! -d "$destination" ] ; then mkdir "$destination"; fi
        unrar e "$archive" "$destination"
      done
  </code></pre>
  
  <p>to do this i.e. run for all rar files in folder/*rar?  Or, use something similar?</p>
  
  <p>Thanks</p>