[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Date Time Stamp

Posted on 2007-09-27
11
Medium Priority
?
1,399 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:lford8300
8 Comments
 
LVL 19

Expert Comment

by:weellio
ID: 19975864
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
 
LVL 19

Expert Comment

by:weellio
ID: 19975950

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
 
LVL 18

Expert Comment

by:BSonPosh
ID: 19982232
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:BSonPosh
ID: 19982238
whoops.. the 1 should be -1 like
where{$_.LastWriteTime -gt ([datetime]:now).addDays(-1)}

This is the number of days.
0
 
LVL 19

Expert Comment

by:weellio
ID: 20115713
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
 

Author Comment

by:lford8300
ID: 20122111
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
 
LVL 19

Accepted Solution

by:
weellio earned 1000 total points
ID: 20143494


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
 
LVL 1

Expert Comment

by:Computer101
ID: 20238444
Forced accept.

Computer101
EE Admin
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question