Author: Jaap Brasser
Date: 05/04/2017 08:49 PM
Size: 57 KB
Requires: Win 10 / 8 / 7
Downloads: 1718 times
Delete Files Older Than X-Days – Cleanup Script is a Powershell script designed to delete old files and generate a log file as a scheduled task.
Delete Files Older Than X-Days offers various levels of logging and the script can also run in -listonly mode so it only lists the files it would otherwise delete.
There are two main routines, one to delete the files and a second routine that checks if there are any empty folders left that could be deleted.
There are also two logging levels available, failed only and verbose, which logs every file and folder that is deleted.
Delete Files Older Than X-Days – Cleanup Script is designed for administrators or advanced users. You can use many switches to get it working however you like. For example, if the following gives you a headache, you might stick with CCleaner:
\deleteold.ps1 -folderpath C:\ -fileage -1 -log c:\log.txt -autolog -verboselog -ListOnly -IncludePath “C:\Users\”,”C:\Windows\Temp\”,”C:\Windows\Prefetch\” -IncludeFileExtension ‘.pf*’,’.log*’,’.iso*’,’.tmp*’,’.bak*’,’.dat*’,’.old*’,’.~??*’,’.chk*’
If you open deleteold.ps1 with Notepad, you can see the many choices you have.
Delete Files Older Than X-Days – Cleanup Script is just a geeky tool for, we think, system admins or anyone with Powershell experience to automate cleanup.