Jump to content
Sign in to follow this  

Open Most Recent/Latest modified file

Recommended Posts

In an attempt to automatically open the most recent file, I came across lots of examples in the forum, but none of them did exactly what I needed, so I played around with them until it worked and here is the code -

#Include <File.au3>
#Include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>
#include <Process.au3>
$dst = "C:\Documents and Settings\user\My Documents" ;specify folder
$a_FileList = _FileListToArray2()
_ArraySort($a_FileList, 1, 1, $a_FileList[0][0], 1)

Func _FileListToArray2($s_Mask='*')
$h_Search = FileFindFirstFile($dst & '\' & $s_Mask)
$s_FileName = FileFindNextFile($h_Search)
If Not @error Then
   Dim $a_File[100][2]
   While Not @error
       if StringInStr($s_FileName,'.',0,-1) Then
           $s_FullName = $dst & '\' & $s_FileName
           $a_File[0][0] += 1
           If $a_File[0][0] >= UBound($a_File) Then
               ReDim $a_File[$a_File[0][0] * 2][2]
           $a_File[$a_File[0][0]][0] = FileGetLongName($s_FullName)
           $a_File[$a_File[0][0]][1] = FileGetTime($s_FullName,0,1)
       $s_FileName = FileFindNextFile($h_Search)
   ReDim $a_File[$a_File[0][0] + 1][2]
   Return $a_File
   Return ''

Hope someone finds it useful.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...