$now = Get-Date Get-ChildItem "C:\Logs" -Filter '*.jrn' | foreach { if ($_.basename -match " $now (?<year>\d{04})(?<month>\d{2})(?<day>\d{2})$") { $fileData = Get-Date -Year $Matches.year -Month $Matches.month -Day $Matches.day ` $_ | Add-Member -MemberType NoteProperty -Name 'DateFromName' -Value $fileData -PassThru } } | Where-Object {($_.DateFromName).addDays(-90) -lt $now} | Remove-Item -Force
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)