If you have a computer that is older than Windows XP, you can delete files older than X days on the computer. To do this, you need to use the Windows XP Delete File Wizard. This wizard will help you delete files older than X days. To start the Delete File Wizard, open the Start menu and type “wizard”. Then, click on the “Delete Files” button. The Delete File Wizard will start. The first step of the Delete File Wizard is to select the file or folders that you want to delete. The next step is to choose how long you want to keep the file or folder after it has been deleted. You can choose either a specific time or a period of time. The last step of the Delete File Wizard is to select how many times you want to delete the file or folder. You can choose one or more times and then click on the “delete” button.


We have already shown you how flexible the Linux shell can be, but that’s not to say Windows is any further behind. Here’s two techniques you can use depending on your shell preference, cmd or PowerShell.

PowerShell 3

PowerShell 2

Explanation

Firstly we get FileInfo and DirectoryInfo objects in the Path C:\Backups. FileInfo and DirectoryInfo objects both contain a CreationTime property, so we can filter the collection using that. The –lt (less than) operator is then used to compare the CreationTime property of the objects with Get-Date (the current date) subtract 5 days. This then leaves us with a collection of objects that were created more than 5 days ago, which we pass to Remove-Item.

Pro Tip

To see what will be removed you can use the –WhatIf parameter:

Command Prompt

While we recommend you use one of the PowerShell methods, without getting into any of the gritty details you can also do it from command prompt.

Pro Tip

To see what files are going to be deleted you can use echo.