title: How to shorten a directory path pattern
body: <p>I have a set of about 10.000 directories that have the following structure</p>
  
  <pre><code>./AAA/AAA/somedirs/file.txt
  ..
  ./BCDE/BCDE/somedirs/file.txt
  ..
  ./FGMAB/FGMAB/somedirs/file.txt
  ..
  etc
  </code></pre>
  
  <p>I want to reduce the recurring directory path pattern of two consecutive directories with the same name:</p>
  
  <pre><code>./X/X/etc/
  </code></pre>
  
  <p>to a single directory with that name:</p>
  
  <pre><code>./X/etc/
  </code></pre>
  
  <p>I thought of finding all substructures after such a X/X pattern and move them to X/  with a command like:</p>
  
  <pre><code>for /r /d %x in (*/%y/%y/*) do move "%x" ".."
  </code></pre>
  
  <p>This does run, but it doesn't seem to actually do anything. </p>
  
  <p>Anyone an idea if and how this could be done?</p>