title: Powershell - how to create directories based on last modify date of files?
body: <p>I'm new to PS. I've found scripts that scan directories (or recursive dirs) and gets the last modified date attribute of a file, but I can't create directories based on this date. What I'm trying to accomplish is something like this:</p>
  
  <p>Date-----------File
  <br>
  2012-01-03   fax1.mfs
  <br>
  2012-01-04   fax2.mfs
  <br>
  2012-01-04   fax3.mfs</p>
  
  <p>Create the following directories:
  <br>
  2012-01-03
  <br>
  2012-01-04</p>
  
  <p>Once we have this we can use another script to move files based on their last modify date.</p>
  
  <p>This is what I've created so far:</p>
  
  <pre><code>Get-ChildItem -Path C:\temp\path | Foreach {$_.LastWriteTime.tostring("MM-dd-yyyy")}
  </code></pre>
  
  <p>Which gives the date in a string format MM-dd-yyyy. I just need to pass that as a variable to something like  </p>
  
  <pre><code>| % {New-Item -Name ($_).tostring("MMddyyyy") -ItemType directory}
  </code></pre>
  
  <p>which errors out and doesn't create any directories. </p>
  
  <p>Any help would be greatly appreciated.</p>