title: Set EXIF DateTaken as file CreationTime
body: <p>I'm trying to fix metadata of my photos using powershell.
  I need to set exif DateTaken as file CreationTime</p>
  
  <p>Here is my code:</p>
  
  <pre><code>[reflection.assembly]::loadfile( "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll")
  echo "--------"
  echo ""
  $files = Get-ChildItem E:\Photos\*.*
  ForEach ($file in $files) {
  
          #Get Date
      $foo=New-Object -TypeName system.drawing.bitmap -ArgumentList $file.fullname 
      $date = $foo.GetPropertyItem(36867).value[0..9]
      $arYear = [Char]$date[0],[Char]$date[1],[Char]$date[2],[Char]$date[3]  
      $arMonth = [Char]$date[5],[Char]$date[6]  
      $arDay = [Char]$date[8],[Char]$date[9]  
      $strYear = [String]::Join('',$arYear)  
      $strMonth = [String]::Join('',$arMonth)   
      $strDay = [String]::Join('',$arDay)  
      $DateTaken = $strDay + "/" + $strMonth + "/" + $strYear
  
  
          # Get Time
      $time = $foo.GetPropertyItem(36867).value[11..18]
      $arHour = [Char]$time[0],[Char]$time[1]
      $arMinute = [Char]$time[3],[Char]$time[4]  
      $arSecond = [Char]$time[6],[Char]$time[7]  
      $strHour = [String]::Join('',$arHour)  
      $strMinute = [String]::Join('',$arMinute)   
      $strSecond = [String]::Join('',$arSecond)  
      $TimeTaken = $strHour + ":" + $strMinute + ":" + $strSecond
  
          # Link into one date and time
      $FullDate = $DateTaken + " " + $TimeTaken
  
      echo "File name"
      echo $file.name
      echo ""
      echo "Wrong data"
      echo (Get-Item $file).creationtime.datetime
      echo ""
      echo "Right data"
      echo $FullDate
      echo ""
  
          #Set DateTaken as CreationTime 
      (Get-Item $file).creationtime= $FullDate
  
      pause
  }
  </code></pre>
  
  <p>I got error "cannot access the file because it is being used by another process".
  I have no idea how to fix it.</p>
  
  <p>PS. I'm not sure if <code>$FullDate</code> has right syntax, because I couldn't test it</p>
  
  <p>Thanks</p>