Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete old files from a directory while keeping the most recent ones on Windows [duplicate]

Possible Duplicate:
Batch file to delete files older than N days

I want to run a scheduled windows task that deletes all files from a directory that are older than 2 weeks.

The reason is that these are IIS and Tomcat logs that fill up my server, but I want to keep the most recent logs in case I need to investigate a problem.

Does any one know an easy way to do this?

Cheers

Nige

like image 316
KiwiNige Avatar asked Sep 08 '08 23:09

KiwiNige


People also ask

How do I delete previous versions of folders?

Press the Windows logo key on your keyboard, then select Settings > System > Storage. Under your hard drive information, select Temporary files. Select the Previous version of Windows check box, and then select Remove files.

Does Windows 10 have a duplicate file finder?

Answer: No, Windows 10 does not have a duplicate finder in it yet.


1 Answers

exact syntax: FORFILES /p d:\new /d -30 /m * /c "cmd /c del @file"

like image 179
subha Avatar answered Oct 06 '22 02:10

subha