ijourneaux Posted August 18, 2010 Posted August 18, 2010 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?
boogieoompa Posted August 19, 2010 Posted August 19, 2010 Store them in an array and the FileGetTime attribute. Once you store them in an array you reference it via the array number +1 or -1 instead of the FileFindNextFile. You will also have to use the _ArraySort UDF given in the help file.
ijourneaux Posted August 23, 2010 Author Posted August 23, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now