ok I know what the issue is, but not how to solve it. basically the process cannot access the file because it is being used by the same code previously. idk just need some way to run this code or something that does the same without the error preventing me from running it.
[reflection.assembly]::LoadWithPartialName("System.Drawing");
foreach ($file in Get-ChildItem)
{
$filePath = "$pwd\$file"
$picDate = $pic.GetPropertyItem(36867).value[0..9]
$pic=New-Object System.Drawing.Bitmap $filePath
$strYear = [String][Char]$picdate[0]+[String][Char]$picdate[1]+[String][Char]$picdate[2]+[String][Char]$picdate[3]
$strMonth = [String][Char]$picdate[5]+[String][Char]$picdate[6]
$strDay = [String][Char]$picdate[8]+[String][Char]$picdate[9]
$DateTaken = $strDay + "/" + $strMonth + "/" + $strYear
$date1 = [datetime]::ParseExact($dateTaken,"dd/MM/yyyy",$Null)
(Get-Item $filePath).CreationTime=($date1)
}
incase you were wondering wtf it's doing. Basically for each file in directory it replaces creationTime with Date taken.