Sunday, May 21, 2017

Delete files older than N days as a service

I have found an issue with (perhaps Microsoft Office 365 client telemetry) that is generating many .CAB and .LOG files that go in my case to the users TEMP folder.

I am sure with more time I could stop it, but as most computers are SSD a space limited, I created a scheduled task for the user that deletes them.

If you just want to see what will be deleted this is the command.

CD %TEMP%
forfiles -p %temp% -s -m *.* /D -5 /C "cmd /c echo @FILE"

Create a CMD file and run this:

This is the delete:
 
CD %TEMP%
forfiles -p %temp% -s -m *.* /D -5 /C "cmd /c del @FILE /f /q"


No comments:

Blog Archive