Jump to content

Process All Files in Folder by date as opposed to name


Recommended Posts

I have a folder where there are several files I need to process. Files get added on a continuous basis. I have been using FileFindFirstFile and FileFindNextFile successfully for a while now but ran into a situation where It would be much better to process the files oldest first. Is there a way to control FileFindNextFile so that it returns the oldest file instead of the first file alphebetically?

Any thoughts on a different approach get process the files oldest first?

Link to comment
Share on other sites

Thanks for the tips.

Here is the solution I came up with.

$FileList=_FileListToArray($Folder, "*." & $extension)
    $err = @error
    
    If (@Error=4) Then
        $filename = ""
    Else
        $UBound = UBound($Filelist)-1

        Dim $CombinedArray[$UBound][2]
        for $i=1 to $Ubound
            $datetime = FileGetTime($folder & "\" & $FileList[$i], 0, 1)
            $CombinedArray[$i-1][0] = $FileList[$i]
            $CombinedArray[$i-1][1] = $datetime
        Next
        _ArraySort($CombinedArray, 0, 0, 0, 1)  
        $filename = $CombinedArray[0][0]
    endif
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...