$Files = Get-ChildItem C:\Users\xxx\Desktop\PRD\Data\03_Processed -Filter *.zip -recurse
#| % {$_.BaseName}
$Days = 10
foreach ($file in $Files)
{
$information = $file
#parse the zipfilename to date
$pattern = '\Proce\s\se\d MMMM dd\, yyyy'
$filedate = ( [datetime]::ParseExact($information, $pattern, $null) )
#check if date from filename is older than X days
if ((Get-date).AddDays(-($Days)) -gt ($filedate)) {remove-item $information -whatif}
}
what's wrong with the remove-item?
it says:
Remove-Item : Cannot find path 'C:\Users\xxx\Desktop\PRD\Batch\Processed May 16, 2014.zip' because it does not exist.
C:\Users\xxx\Desktop\PRD\Batch\ - is the path of my script