title: Move folders to the respective sub-folders using the folder name key
body: <p>I want to move folders to the respective sub-folders if there is at least one word in the folder name that is the same as the subfolder.<br></p>
  
  <p>I use this code to move files into folders but I need to do same thing to move <em>folders</em> into other folders</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  pushd %1
  for /F "USEBACKQ tokens=*" %%a in (`dir /b /a:-d`) do (
      set "_file=%%a"
      for /D %%b in (*) do (
          if NOT "x!_file:%%b=!" == "x!_file!" (
              move "%%a" "%%b"
          )
      )
  )
  popd
  </code></pre>
  
  <p>EDIT: example</p>
  
  <p>I create before theses folders</p>
  
  <pre><code>Waking The Dead
  Lost.dt%ky
  </code></pre>
  
  <p>I have these folders</p>
  
  <pre><code>Waking The Dead s01
  Waking The Dead s02
  Lost.dt%ky.rang200
  </code></pre>
  
  <p>I want to move these folders </p>
  
  <pre><code>Waking The Dead s01
  Waking The Dead s02
  </code></pre>
  
  <p>into</p>
  
  <pre><code>Waking The Dead
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Lost.dt%ky.rang200
  </code></pre>
  
  <p>into</p>
  
  <pre><code>Lost.dt%ky
  </code></pre>