Batch file to delete files older than N days
Batch file to delete files older than N days
Batch file to delete files older than N days
Re: Batch file to delete files older than N days
Enjoy:
```
forfiles -p "C:\what\ever" -s -m *.* -d -c "cmd /c del @path"
```
See [`forfiles` documentation](http://ss64.com/nt/forfiles.html) for more details.
For more goodies, refer to *[An A-Z Index of the Windows XP command line](http://www.ss64.com/nt/)*.
If you don't have `forfiles` installed on your machine, copy it from any [Windows Server 2003](http://en.wikipedia.org/wiki/Windows_Server_2003) to your Windows XP machine at `%WinDir%\system32\`. This is possible since the EXE is fully compatible between Windows Server 2003 and Windows XP.
Later versions of Windows and Windows Server have it installed by default.
For Windows 7 and newer (including Windows 10):
The syntax has changed a little. Therefore the updated command is:
```
forfiles /p "C:\what\ever" /s /m *.* /D - /C "cmd /c del @path"
```
```
forfiles -p "C:\what\ever" -s -m *.* -d
```
See [`forfiles` documentation](http://ss64.com/nt/forfiles.html) for more details.
For more goodies, refer to *[An A-Z Index of the Windows XP command line](http://www.ss64.com/nt/)*.
If you don't have `forfiles` installed on your machine, copy it from any [Windows Server 2003](http://en.wikipedia.org/wiki/Windows_Server_2003) to your Windows XP machine at `%WinDir%\system32\`. This is possible since the EXE is fully compatible between Windows Server 2003 and Windows XP.
Later versions of Windows and Windows Server have it installed by default.
For Windows 7 and newer (including Windows 10):
The syntax has changed a little. Therefore the updated command is:
```
forfiles /p "C:\what\ever" /s /m *.* /D -
```