I need to select images based on size, width, and datemodified, and move them, as well as rename them. Here is my script so far:
Add-Type -Assembly System.Drawing
Get-ChildItem -path C:empimages |
Where-Object { $_.Length -ge 250Kb -and $_.lastwritetime -gt (get-date).addDays(-5) -and [Drawing.Image]::FromFile($_.FullName).Width -eq 1920 } |
move-item –PassThru | Rename-Item -NewName {-join @($_.Name,'.jpg')}
The problem is FromFile method is locking the file and preventing the move with this error message:
move-item : The process cannot access the file because it is being
used by another process.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…