I have a requirement to replace a load (2000+) images within the Sitecore media library with optimised images with the same name. I need to keep the original GUIDS so that all images are still linked.
So I basically need to replace the image blob data and size data. I have written a powershell script to do this however I have found it consistently will all process 100 items. I can not see any reason for this, it could just be my script is rubbish as i haven't used powershell much before.
$CurrentImages = Get-Item -Path master: -Query '/sitecore/media library/Images/Products//*[@@TemplateName="Jpeg"]';
$NewImages = Get-Item -Path master: -Query '/sitecore/media library/NewImages//*[@@TemplateName="Jpeg"]';
Write-Host $NewImages.Count;
$CurrentImages|foreach{ $Current = $_; $NewImages|foreach{ $New = $_; if($New.DisplayName -eq $Current.DisplayName){ Write-Host $Current.DisplayName; $Current.Blob = $New.Blob; $Current.Size = $New.Size; $New | Remove-Item}}};
Im using the sitecore powershell extention if that also helps