Sign in to follow this  
Followers 0
Grantgimp

Open Most Recent/Latest modified file

2 posts in this topic

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)
ShellExecute($a_FileList[1][0])


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]
           EndIf
           $a_File[$a_File[0][0]][0] = FileGetLongName($s_FullName)
           $a_File[$a_File[0][0]][1] = FileGetTime($s_FullName,0,1)
       EndIf
       $s_FileName = FileFindNextFile($h_Search)
   WEnd
   ReDim $a_File[$a_File[0][0] + 1][2]
   Return $a_File
Else
   Return ''
EndIf
EndFunc

Hope someone finds it useful.

Share this post


Link to post
Share on other sites



It can be usefull Posted Image

Thanks


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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  
Followers 0