不包括今天的文件的 FORFILES 不起作用

FORFILES not including today's files is not working

阅读页面:http://blogs.msdn.com/b/oldnewthing/archive/2012/08/03/10334560.aspx

我们看到他讨论:/D +0 的使用和使用 /D -0 不包括今天创建的文件是有道理的。

我正在做一个 web 存档项目,并且非常接近这个..

FORFILES /P D:\logs\ /M dump.log* /D -0  /C "cmd /c ECHO @file"
FORFILES /P D:\logs\ /M server.log* /D -0  /C "cmd /c ECHO @file"

事实上,无论使用 /D -0 还是 /D +0,我都得到相同的结果

/D 是日期偏移量。通常,它后面跟着一个负数,表示对于最后修改日期小于或等于指定偏移量的文件,该命令应为 运行。在极少数情况下,+0 可用于最后修改日期晚于今天的文件。

要在处理时忽略今天的文件,请使用 /D -1 处理所有其他文件...除非您有将来的文件。

日期select离子是

/d +date  files with date >= to the indicated date
/d -date  files widh date <= to the indicated date
/d +n     files with date >= to today-n days
/d -n     files with date <= to today-n days

所以根据 daten 的值选择一个时间点,然后 +- selects 如果selected 文件较新 (-) 或较旧 (+)(或在两种情况下都相同)到指定点。

因此,对于 select,除今天 /d -1 更改的文件外,所有文件都应使用。也就是说,我们 select 昨天的日期 (1) 然后所有日期低于或等于 (-) 的文件到这一点

/d +0 将选择今天的日期 (today - 0) 和 select 日期大于或等于 (+) 的文件,因此, selected 是今天更改的文件。