You can run external DIR with redirection than read the first line or loop through all files and compare their dates, both examples are below. Example 1: RunAndWait("cmd DIR /B/o-D c:\\mydir\\*.* > c:\\temp\\list.txt", "", 0, process) FileReadLine("c:\\temp\\list.txt", 1, file_name) Example 2: You should get of each file date and time in a loop and then compare them to find the most recent. Dim max_dt, datetime Dim recent_file, string Dim older, boolean .... other declaration go here .... FindFileFirst "c:\\mydir\\*.*", file_name, found LoopWhile found, END_LOOP FileDate file_name, date_val FileTime file_name, time_val MakeDateTime date_val, time_val, datetim_val isLess datetim_val, max_dt, older IfThen older, GET_NEXT Set max_dt, datetime, val Set recent_file, file_name GET_NEXT: FindFileNext file_name, found END_LOOP: // ok , recent_file variable has the name of the most recent file : Has anyone got a script that gets the most recent file in a directory? I am : trying to automate emailing a backup file and FileFindFirst seems to not : have a sort option. I am using ver 2.4. : Cheers, : Jane
|