dazza Posted October 20, 2008 Posted October 20, 2008 Why does this code: $search = FileFindFirstFile("C:\Program Files\Combat\Combat\syslog*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($file,0,0) msgbox (0, $file, $t[2]) WEnd FileClose($search) kick out: U:\SLAG.au3 (55) : ==> Subscript used with non-Array variable.: msgbox (0, $file, $t[2]) msgbox (0, $file, $t^ ERROR I just want to check the last modified/created date of all files in a specified folder.
Andreik Posted October 20, 2008 Posted October 20, 2008 Why does this code: $search = FileFindFirstFile("C:\Program Files\Combat\Combat\syslog*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($file,0,0) msgbox (0, $file, $t[2]) WEnd FileClose($search) kick out: U:\SLAG.au3 (55) : ==> Subscript used with non-Array variable.: msgbox (0, $file, $t[2]) msgbox (0, $file, $t^ ERROR I just want to check the last modified/created date of all files in a specified folder.Try this: $path = FileSelectFolder("SELECT","") $search = FileFindFirstFile($path & "\*.*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($file,0,0) msgbox (0, $file, $t[2]) WEnd FileClose($search)
weaponx Posted October 20, 2008 Posted October 20, 2008 $path = "C:\Program Files\Combat\Combat\" $search = FileFindFirstFile($path & "syslog*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($path & $file,0,0) If @ERROR Then MsgBox(0,"","Error getting time from file:" & @CRLF & $file) MsgBox (0, $file, $t[2]) WEnd
dazza Posted October 20, 2008 Author Posted October 20, 2008 Try this: $path = FileSelectFolder("SELECT","") $search = FileFindFirstFile($path & "\*.*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($file,0,0) msgbox (0, $file, $t[2]) WEnd FileClose($search) Nope. Still the same error.
Andreik Posted October 20, 2008 Posted October 20, 2008 (edited) Or you can use FileListToArray: #include <File.au3> $PATH = FileSelectFolder("SELECT","") $FILE = _FileListToArray($PATH,"*",1) If IsArray($FILE) Then For $INDEX = 1 To $FILE[0] $TIME = FileGetTime($PATH & "\" & $FILE[$INDEX]) MsgBox(0,$FILE[$INDEX],$TIME[2]) Next EndIf Edited October 20, 2008 by Andreik
dazza Posted October 20, 2008 Author Posted October 20, 2008 $path = "C:\Program Files\Combat\Combat\" $search = FileFindFirstFile($path & "syslog*") While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $t = FileGetTime($path & $file,0,0) If @ERROR Then MsgBox(0,"","Error getting time from file:" & @CRLF & $file) MsgBox (0, $file, $t[2]) WEnd This works! I cannot see why but hell, it does. Many thanks!
dazza Posted October 20, 2008 Author Posted October 20, 2008 Or you can use FileListToArray: #include <File.au3> $PATH = FileSelectFolder("SELECT","") $FILE = _FileListToArray($PATH,"*",1) If IsArray($FILE) Then For $INDEX = 1 To $FILE[0] $TIME = FileGetTime($FILE[$INDEX]) MsgBox(0,$FILE[$INDEX],$TIME[2]) Next EndIf I'll add that to my arsenal. Many thanks.
weaponx Posted October 20, 2008 Posted October 20, 2008 You weren't supplying the full path to the file for FileGetTime...
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