' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
oldfnm = ""
olddlm = "01-01-2100 00:00:00"
Set fso = CreateObject("Scripting.FileSystemObject")
Set dir = fso.GetFolder("C:\")
For Each f in dir.Files
    WScript.Echo f.Name & " " & f.DateLastModified
    If DateDiff("s", olddlm, f.DateLastModified) < 0 Then
        oldfnm = f.Name
        olddlm = f.DateLastModified
    End If
Next
Set dir = Nothing
Set fso = Nothing
WScript.Echo "Oldest file: " & oldfnm & " " & olddlm
