How can I change this VBScript to return only the newest file name and Last Modified date? It currently returns all changes in the last 24 hours. I want to search only the last file. I borrowed this from StackOverflow, not yet a VBScript wizard.
option explicit
dim fileSystem, folder, file
dim path
path = "C:\test"
Set fileSystem = CreateObject("Scripting.FileSystemObject")
Set folder = fileSystem.GetFolder(path)
for each file in folder.Files
if file.DateLastModified > dateadd("h", -24, Now) then
'whatever you want to do to process'
WScript.Echo file.Name & " last modified at " & file.DateLastModified
end if
next
source
share