;========================================================================================================================================== ; ; How to find the newest or the oldest file in folder? ; ;------------------------------------------------------------------------------------------------------------------------------------------ ; (c)Detlev Dalitz.20110608. ;========================================================================================================================================== strFileMask = Environment ("TEMP") : "\*.*" ; Find the newest File, Method 1. arrFI = FileInfoToArray (strFileMask) ArraySort (arrFI, @ASCENDING, 2, 1) strFileNewest1 = arrFI [arrFI[0, 0], 0] ; Find the newest File, Method 2. arrFI = FileInfoToArray (strFileMask) ArraySort (arrFI, @DESCENDING, 2, 1) strFileNewest2 = arrFI [1, 0] ; Find the oldest File, Method 1. arrFI = FileInfoToArray (strFileMask) ArraySort (arrFI, @DESCENDING, 2, 1) strFileOldest1 = arrFI [arrFI[0, 0], 0] ; Find the oldest File, Method 2. arrFI = FileInfoToArray (strFileMask) ArraySort (arrFI, @ASCENDING, 2, 1) strFileOldest2 = arrFI [1, 0] :CANCEL Exit