开发者

Batch File to Determine Modified Dates

Hey guys, I'm looking for a batch file to tell me if certain folders have been modified today (I'll run it every morning). I'm happy to s开发者_StackOverflow中文版pecify each of the folders to be to be queried, I just haven't been able to find anything that meets my requirements yet. If anyone knows off the top of their head what the code for the .bat would be, that would be awesome :) Thanks in advance.


Here's a batch file that should do the trick:

@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
for /D %%Q IN (*.*) DO (
  set FILETIME=%%~tQ
  if "!FILETIME:~0,10!"=="%DATE:~4%" echo %%Q
)

This works by comparing the date-part of the file timestamp against the current date.

As written, it checks directories in the current directory, but you could replace *.* with whatever filespec you want to test (or pass it in as an argument).

I don't know if this will work on systems with anything other default English/US regional settings, but it could probably be tweaked to make it work, if it doesn't already. I also don't know what would happen if the system is shared between users in different time-zones.


you can use a vbscript

Set objFS = CreateObject( "Scripting.FileSystemObject" )
strFolder = WScript.Arguments(0)
Set objFolder = objFS.GetFolder(strFolder)
If DateDiff("d", Now, objFolder.DateLastModified ) = 0 Then
    WScript.Echo "0"
End If 

in your batch file (or command line)

C:\test>cscript //nologo test.vbs myFolderName

use a for loop to catch the output. (Or you can even do everything in vbscript )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜