title: How to merge / 'flatten' a folder structure using PowerShell - recursive
body: <p>I'm looking for help restructuring a large number of files within many subfolders.</p>
  
  <p>Example source:</p>
  
  <pre><code>folderX
     aaa.txt
     bbb.txt
  folderY
     ccc.txt
     folderZ
        ddd.txt
  eee.txt
  </code></pre>
  
  <p>Ideal result:</p>
  
  <pre><code>folderX_aaa.txt
  folderX_aaa.txt
  folderX_bbb.txt
  folderY_ccc.txt
  folderY_folderZ_ddd.txt
  eee.txt
  </code></pre>
  
  <p>I hope that makes sense! I'm using Plex to manage some media and it doesn't like subfolders for certain uses (eg featurettes directory).</p>
  
  <p>I'd like to use PowerShell because I'm already kinda familiar with it - but any techniques or suggestions are welcome.</p>
  
  <p>Thanks in advance :)</p>