title: Get creation date with format
body: <p>I want to loop over images and move each into a folder of the creation date, but I seem to fail to see the point about how to format the resulting datetime string and maybe also how ChildItem works...</p>
  
  <p>I intend to create a variable containing the correct formatted string of the creation date "2017-03-06", so that I can create a directory with that name and move the file there. This shall happen within a loop (<code>for</code>, <code>foreach</code>, ...).</p>
  
  <pre class="lang-cs prettyprint-override"><code>$files = Get-ChildItem "P:\photos\"
  
  for ($i=0; $i -lt $files.Count; $i++) {
      $outfile = $files[$i].FullName
      Write-Host "file: " $outfile
      $CreationDateStr = Get-ChildItem  $files[$i].CreationTime |
                         Get-Date -f "yyyy-MM-dd"
      Write-Host "file creation time: " $CreationDateStr
  }
  
  Read-Host -Prompt "Press Enter to exit"
  </code></pre>
  
  <p>This does not work, and the code is not correct:</p>
  
  <blockquote>
    <p>Get-ChildItem : The disc was not found. Not disc with name "03/06/2017 07"</p>
  </blockquote>
  
  <p>This works, but it needs to be formatted:</p>
  
  <pre><code>$files[$i].CreationTime
  </code></pre>
  
  <blockquote>
    <p>file creation time:  06.03.2017 07:53:21</p>
  </blockquote>