如何在保留Windows最新文件的同时从目录中删除旧文件 [英] How do I delete old files from a directory while keeping the most recent ones on Windows
本文介绍了如何在保留Windows最新文件的同时从目录中删除旧文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
批处理文件以删除早于N天的文件
Possible Duplicate:
Batch file to delete files older than N days
我想运行一个计划的Windows任务,该任务将从2周之前的目录中删除所有文件.
I want to run a scheduled windows task that deletes all files from a directory that are older than 2 weeks.
原因是这些是填满我的服务器的IIS和Tomcat日志,但是我想保留最新的日志,以防需要调查问题.
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?
欢呼
尼日
推荐答案
确切语法: FORFILES /p d:\new /d -30 /m * /c "cmd /c del @file"
这篇关于如何在保留Windows最新文件的同时从目录中删除旧文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文