Sign in to follow this  
Followers 0
Unity Card

Looking at file dates and assign file name to a variable

3 posts in this topic

Is it possible to use AutoIt to look at all the files in a folder and assigning the file name with the oldest date to a variable?

Please let me know as I couldn't find anything that would help...thank you!

Share this post


Link to post
Share on other sites



Is it possible to use AutoIt to look at all the files in a folder and assigning the file name with the oldest date to a variable?

Please let me know as I couldn't find anything that would help...thank you!

Hi,

I dunno what you exactly want to do, but until the word folder Ican say yes that is possible.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

$hSearch = FileFindFirstFile("*.*")
If $hSearch = -1 Then
    MsgBox(16, "FileFindFirstFile", "An error occured !")
    Exit
EndIf

$sOldFile = ""
$iOldTime = 0

While 1
    $sCheckFile = FileFindNextFile($hSearch)
    If @error Then ExitLoop
    
    $iCheckTime = FileGetTime($sCheckFile, 1, 1)
    If $iOldTime = 0 OR $iCheckTime < $iOldTime Then
        $sOldFile = $sCheckFile
        $iOldTime = $iCheckTime
    EndIf
    
WEnd

If $sOldFile = "" Then
    MsgBox(16, "Failure", "Failed to find the oldest file.")
Else
    MsgBox(64, "Success", "File : " & $sOldFile & @CRLF & "Time : " & $iOldTime)
EndIf

Currently is gives you the oldes created file, but if you instead want the

access- or modified-time then just change the second parameter in FileGetTime.

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