Hey everybody
I'm having an issue with OP's question, something strange.
I tested his script on a folder named C:\Temp7 containing 4 files :
test part2.exe (this 1st file got a creation time = 05:17:01 as shown in Windows Explorer)
vtest part1.a3x
vtest part1.au3
vtest part1.exe
If I run the following script (based on OP's script & JLogan3o13's suggestion), then it works fine for the 1st file...
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
$filePath = "C:\Temp7" ; or "C:\Temp7\"
$fileList = _FileListToArrayRec($filePath, "*", $FLTAR_FILES, $FLTAR_NORECUR , $FLTAR_NOSORT , $FLTAR_NOPATH)
; $fileList = _FileListToArrayRec($filePath, "*", $FLTAR_FILES, $FLTAR_NORECUR , $FLTAR_NOSORT , $FLTAR_RELPATH)
; $fileList = _FileListToArrayRec($filePath, "*", $FLTAR_FILES, $FLTAR_NORECUR , $FLTAR_NOSORT , $FLTAR_FULLPATH) ; (+++)
; $fileList = _FileListToArray($filePath, "*", $FLTA_FILES , False) ; False = no fullpath appended
; $fileList = _FileListToArray($filePath, "*", $FLTA_FILES , True) ; True = fullpath appended (+++)
_ArrayDisplay($fileList)
For $i = 1 To $fileList[0]
$aGetTime = FileGetTime($fileList[$i], $FT_CREATED, $FT_ARRAY)
ConsoleWrite("@error = " & @error & " " & $fileList[$i] & @crlf)
If $aGetTime[3] >= 1 And $aGetTime[3] <= 12 Then
MsgBox(0, $fileList[$i], "File created (hhmmss) : " & $aGetTime[3] & $aGetTime[4] & $aGetTime[5])
Else
MsgBox(0, $fileList[$i], "Failed")
EndIf
Next
...then the scripts ends with an error. AutoIt Console :
@error = 0 test part2.exe
@error = 1 vtest part1.a3x
"script path here...294.au3" (24) : ==> Subscript used on non-accessible variable.:
If $aGetTime[3] >= 1 And $aGetTime[3] <= 12 Then
If $aGetTime^ ERROR
>Exit code: 1 Time: 3.944
The error seems easy to solve : the fullpath should be appended as last parameter in _FileListToArrayRec() or _FileListToArray(), but OP didn't append it, this created the issue.
This being said, an important question isn't answered : why FileGetTime() didn't throw an error for the 1st file ?
Nothing in the array shown in the pic above indicates to FileGetTime() where to find the 1st file, so how FileGetTime() did find the path of the 1st file ? And if it found the 1st file path, why not doing same for the 3 other files ?
* Please note that even if the 1st file has been processed by FileGetTime(), without @error, the file creation time shown in the precedent pic isn't accurate, it should be 05h17m01s and not 05h16m53s as shown in the pic above. The accurate creation time would be displayed correctly only if we append the full path in the _FileListToArrayRec() or _FileListToArray() functions (tested).
* Could this strange behavior be related to the FindFirstFile windows API, its search handle and the dozen of remarks found on msdn ? FindFirstFile is used in both functions _FileListToArrayRec() and _FileListToArray()
It's interesting to note that there's never an issue with FileGetTime() when there's only 1 file to process, even if we make a "mistake" by not appending the full path in _FileListToArrayRec() or _FileListToArray() functions. As soon as there's a loop and several files are retrieved, then the issue always appears for the 2nd file processed by FileGetTime() and also @error = 1 for all the remaining files (when we don't indicate a full path as last parameter)
Let's hope I didn't miss something obvious. Maybe it's a bug that should be reported : imho FileGetTime() shouldn't process the 1st file at all in the preceding script... but it does !