Date Time Stamp

I need a script that will check the date stamp of all files in a specified directory and it's subdirectories.  If the date stamp is older than a specified number of days, report the file name to a text file.
lford8300Asked:
Who is Participating?
 
William ElliottConnect With a Mentor Sr Tech GuruCommented:


Dim Fso, Directory, Modified, Files, FSO, objoutputfile
strOutputFile = "c:\scripts\myfile.txt"
strdays = inputbox("Older than how many days?")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = fso.CreateTextFile(strOutputFile, TRUE)
Set Directory = Fso.GetFolder("c:\scripts")
Set Files = Directory.Files
For Each Modified in Files
      If DateDiff("D", Modified.DateLastModified, Now) < strdays Then
            objOutputFile.writeline Modified.DateLastModified & "     " & Modified.name & "     " &  Modified.path
                  Strbody = Strbody & Modified.DateLastModified & "     " & Modified.name & "     " &  Modified.path
      end if
Next
objOutputFile.close

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Old files"
objMessage.From = "me@my.com"
objMessage.To = "someone@somewhere.com"
objMessage.TextBody = strbody

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myserver.com" '<==change that

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
 
0
 
William ElliottSr Tech GuruCommented:
xcopy *.* /D:01-01-2007  /L c:\location >> filename.txt

xcopy - program
*.* - what to look at
/D: - copy name since
/L - only name, no actual copy
c:\location - where to copy to (even though you are not copying)
>> - append results to file
filename.txt - file to append results.


hmm,. this might be the opposite of what you want,..
0
 
William ElliottSr Tech GuruCommented:

Dim Fso, Directory, Modified, Files, FSO, objoutputfile
strOutputFile = "c:\scripts\myfile.txt"
strdays = inputbox("Older than how many days?")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = fso.CreateTextFile(strOutputFile, TRUE)
Set Directory = Fso.GetFolder("c:\scripts")
Set Files = Directory.Files
For Each Modified in Files
      If DateDiff("D", Modified.DateLastModified, Now) < strdays Then
            objOutputFile.writeline Modified.DateLastModified & "     " & Modified.name & "     " &  Modified.path
      end if
Next
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
BSonPoshCommented:
In Powershell this is one line.
Get-childitem c:\folder -rec | where{$_.LastWriteTime -gt ([datetime]:now).addDays(1)} | foreach{$_.Fullname} | out-file Filename.txt -enc ASCII
0
 
BSonPoshCommented:
whoops.. the 1 should be -1 like
where{$_.LastWriteTime -gt ([datetime]:now).addDays(-1)}

This is the number of days.
0
 
William ElliottSr Tech GuruCommented:
this might be useful to others on the web. why not Paq and split?
or do you think there are enough version of this out there already?
curious,.
0
 
lford8300Author Commented:
A change in the specification since the first post, The user wants to receive an automated e-mail message if any file in a specific directory is older than three days.
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.