So, I have a directory of pictures for a website. There are pictures that are the same with both a .jpeg
extension and a .webp
extension. I want to write a PowerShell script that finds all the existing .jpeg
files that changed in the last 24 hours, and then find the respective .webp
file and delete the .webp
file.
I've tried this to get all the .webp
files that can be deleted but it doesn't seem to work:
$images = Get-ChildItem -Path $dir*.jpg, $dir*.webp |
Group-Object { $_.BaseName } |
Where-Object {($_.CreationTime -gt (Get-Date).AddDays(-1)) -or ($_.Group.Extension -notcontains '.jpg')} |
ForEach-Object Group
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…