Link to home
Create AccountLog in
Avatar of lford8300
lford8300

asked on

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.
Avatar of William Elliott
William Elliott
Flag of United States of America image

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,..

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
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
whoops.. the 1 should be -1 like
where{$_.LastWriteTime -gt ([datetime]:now).addDays(-1)}

This is the number of days.
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,.
Avatar of lford8300
lford8300

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of William Elliott
William Elliott
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Forced accept.

Computer101
EE Admin