1.

Solve : Batch script to check if last modified date is earlier than current day?

Answer»

I need to create a batch file to check the last modified date of a directory and if it's older than the current date i need to execute foo.com. Can someone assist?

Thanks.."foo.com" - what kind of a name is that? Just a generic name given since the name of the program isn't important. We could say I wanted to run 'KingKong.exe" OK. I just hate all that foo and bar stuff. Have done since my UNIX days.

.com means a DOS executable. But I guess again that's just an example.

What is your local date and time format setting?

Ya, I'm a LINUX admin

Anyways, I ended up piecing together some VB code and I think I am accomplishing what I want..

Dim fso, f, f1, fc
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\temp\")
Set fc = f.Files
For Each f1 in fc
If DateDiff("d", f1.DateLastModified, Now) > 30 Then
WshShell.Run "bmail -s smtp1 -t [emailprotected] -f [emailprotected] -h -a Logging_Stopped"
End If
Next
Set fso = Nothing
Set f = Nothing
Set fc = Nothing Quote from: rmcc4444 on October 30, 2009, 12:18:43 PM

Ya, I'm a Linux admin
if you have been a linux admin AND if you can use *nix stuff on your WINDOWS environment, you can download GNU tools (SEE my SIG) and use them. After that i am sure you know how to use GNU find to search for files older than 30 days and delete them


Discussion

No Comment Found