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.
Dim Fso, Directory, Modified, Files, FSO, objoutputfile
strOutputFile = "c:\scripts\myfile.txt"
strdays = inputbox("Older than how many days?")
Set Fso = CreateObject("Scripting.Fi
Set objOutputFile = fso.CreateTextFile(strOutp
Set Directory = Fso.GetFolder("c:\scripts"
Set Files = Directory.Files
For Each Modified in Files
If DateDiff("D", Modified.DateLastModified,
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
Get-childitem c:\folder -rec | where{$_.LastWriteTime -gt ([datetime]:now).addDays(1
whoops.. the 1 should be -1 like
where{$_.LastWriteTime -gt ([datetime]:now).addDays(- 1)}
This is the number of days.
where{$_.LastWriteTime -gt ([datetime]:now).addDays(-
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,.
or do you think there are enough version of this out there already?
curious,.
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
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,..