title: Powershell to Split huge folder in multiple folders
body: <p>I have a folder that contains many huge files. I want to split these files in 3 folders. The requirement is to get the count of files in main folder and then equally split those files in 3 child folders.
  Example - Main folder has 100 files. When I run the powershell, 3 child folders should be created with 33, 33 and 34 files respectively.
  How can we do this using Powershell?</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>$FileCount = (Get-ChildItem C:\MainFolder).count 
  Get-ChildItem C:\MainFolder -r | Foreach -Begin {$i = $j = 0} -Process { 
    if ($i++ % $FileCount -eq 0) { 
      $dest = "C:\Child$j" 
      md $dest 
      $j++ 
    } 
    Move-Item $_ $dest 
  } 
  </code></pre>