I would suggest 2 methods 1. Here is the idea - loop though all files and compare their date/times. This is the most reliable method but more complicated. Dim( best_time, datetime, "01-01-1900 00:00") Dim( best_file, string ) Dim( list_length, number ) .... Dir("dir name", list) Length(list, list_length) LoopWhile(list_length, END_LOOP) GetToken( ",", list, file_name ) FileDate(file_name, file_date) FileTime(file_name, file_date) MakeDateTime( file_date, file_time, file_datetime ) IsLess( file_datetime, best_time, older_file ) IfThen( older_file, SKIP) Set( best_time, file_datetime ) Set( best_file, file_name ) SKIP: Length(list, list_length) END_LOOP: // here you are. If best_file is not empty you, found it. 2. Method 2 - use DOS dir with sort options and then and parse the output RunAndWait ("dir /O-D dir name > dir.log", "", 0, pid) FileReadLine("dir.log", 6, line) GetToken(" ", line, file_date) GetToken(" ", line, file_time) Trim(line, line) GetToken(" ", line, file_size) GetToken(" ", line, file_name) Hope that helps. : Is there a way to extract the "yonger" file : from a folder? : Thanks.
|