1
forfiles -p "C:\what\ever" -s -m *.* /D -<number of days> /C "cmd /c del @path"

I am using the above set to 90 days. It does not want to delete files previous unless set to 30 days. Not sure what I am missing.

DavidPostill
  • 156,873
daryl
  • 11
  • What operating system? Do you have a preferred programming or scripting language? Please fill in details and context for your question so that we can get you the best possible answer. Also, have you tried anything yet? Have you done any research and tried solutions that have not worked? – music2myear Feb 23 '17 at 22:54
  • Try using .... forfiles -p "C:\what\ever" /s /m *.* /d -30 -c "CMD /C DEL /Q @file"... let me know if that helps you and if you want me to add an answer. – Vomit IT - Chunky Mess Style Feb 24 '17 at 07:13

1 Answers1

1

Here's the Powershell way:

$limit = (Get-Date).AddDays(-30)
Get-ChildItem -Path "C:\Path\Whatever" -Recurse | Where-Object {$_.LastWriteTime -lt $limit} | Remove-Item