检查文件后,在过去xx天修改

编程入门 行业动态 更新时间:2024-10-24 23:29:08
本文介绍了检查文件后,在过去xx天修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我检查用于在文件修改的日期。我想测试文件是否在 /天-3 后修改。按照文档,这将检查文件之前修改该日期。我需要检查,如果该文件是在该日期之后修改。该文档还指出,我可以指定一个日期。这样我可能会做这种方式虽然这将是一个有点复杂,生成日期核对,我会preFER尽量避免。我怎么可能去呢?

I am checking for the date modified in a file. I would like to test whether the file was modified after the /d -3. According to the docs, this will check if the file was modified before that date. I need to check if the file was modified after that date. The docs also state that I can specify a date. I might end up doing it this way though it would be a little more complicated to generate a date to check against which I would prefer to avoid if possible. How might I go about this?

forfiles /m Item_Lookup2.csv /d -3 >nul 2>nul && ( echo - updated goto :PROCESS_FILE ) || ( echo - out of date set outdated="true" goto :CHECK_ERRORS )

我发现这个答案此

推荐答案

您是在正确的轨道上,但 FORFILES / D -n 的文件测试修改的 N 的天或更早,而不是以后。你需要做的是扭转你的&放大器;&安培; 和 || code块,也许指定4天代替3-

You're on the right track, but forfiles /d -n tests for files modified n days or earlier, not later. What you need to do is reverse your && and || code blocks, and maybe specify 4 days instead of 3.

如果匹配,那么它是由4个天以上,并归为过时。如果没有匹配,它已经在过去3天内更新。

If match, then it's 4 days old or older, and classified as out of date. If no match, it's been updated in the past 3 days.

试试这个:

forfiles /d -4 /m "Item_Lookup2.csv" >NUL 2>NUL && ( echo - out of date set outdated="true" goto :CHECK_ERRORS ) || ( echo - updated goto :PROCESS_FILE )

特别提示:如果您想进行一些测试,您可以使用PowerShell命令手动操纵文件的最后修改时间戳记:

Bonus tip: If you'd like to do some testing, you can manipulate the last modified timestamp of a file manually using a PowerShell command:

powershell "(gi Item_Lookup2.csv).LastWriteTime='6/1/2015 09:30:00 AM'"

... ...将Item_Lookup2.csv最后修改的时间戳上午9:30设置为6月1日。盐适量。

... will set the last modified timestamp of Item_Lookup2.csv to June 1 at 9:30 AM. Salt to taste.

更多推荐

检查文件后,在过去xx天修改

本文发布于:2023-11-27 10:19:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637672.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   在过去   xx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!