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 回答1: exact syntax: FORFILES /p d:\new /d -30 /m * /c "cmd /c del @file" 回答2: The simplest way would be a .bat run