TDS Posted October 15 Share Posted October 15 Could use a help here below is my code up until the point where it errors out my issue here is it seems like FileGetTime won't output anything the msgbox ive inserted reports back a correct file name, ive tried FileGetTime($File,0) FileGetTime($File,0,0) FileGetTime($File,0,1) ect , I cannot seem to get $FDate to read as anything despite $file being valid, I'm sure I'm missing something simple, any ideas? error is ""C:\Temp\AutoIT Tempfolder.au3" (27) : ==> Subscript used on non-accessible variable.:" which makes me think maybe $FDate is being declared wrong #include <Date.au3> #include <Excel.au3> $iTodaysDate = _NowCalc() $search = FileFindFirstFile("C:\temp\runningprogress\*.csv") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") winclose("C:\windows\system32\cmd.exe") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $FDate = FileGetTime($file, 0) msgbox(0,"",$file & " " & $FDate) ; inserted for troubleshooting $FileDate = $FDate[0] & "/" & $FDate[1] & "/" & $FDate[2] & " " & $FDate[3] & ":" & $FDate[4] & ":" & $FDate[5] If _DateDiff('D', $FileDate, $iTodaysDate) < 2 Then FileCopy($file, "C:\temp\currentday\" & $file, 1) EndIf WEnd Link to comment Share on other sites More sharing options...
argumentum Posted October 15 Share Posted October 15 (edited) 10 minutes ago, TDS said: $FDate = FileGetTime($file, 0) msgbox(0,"",$file & " " & $FDate) ; inserted for troubleshooting Success: an array or string that contains the file time information. See Remarks. Failure: sets the @error flag to non-zero. $FDate = FileGetTime($file, 0) If @error Then ; inserted for troubleshooting ConsoleWrite('! error with "' & $file & '" at # ' & @ScriptLineNumber & @CRLF) ContinueLoop EndIf Edited October 15 by argumentum added example pixelsearch 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
TDS Posted October 15 Author Share Posted October 15 yes, it is outputting blank / or an error, i would assume, if I knew how to output that flag I do not know why, $file reports back a valid file name (in your quoted message box), though it doesn't include the full path, just the file name Link to comment Share on other sites More sharing options...
TDS Posted October 15 Author Share Posted October 15 Actually I got it, it seems I had to re-insert the file path, I assumed the findnextfile was outputting a reference I could use, by putting the file path back into filegettime and appending the file name to the end it seems to work now Link to comment Share on other sites More sharing options...
argumentum Posted October 15 Share Posted October 15 4 minutes ago, TDS said: Actually I got it, ... #include <Date.au3> #include <Excel.au3> myFuncForThis("C:\temp\runningprogress", "*.csv", "C:\temp\currentday") Func myFuncForThis($sPath, $sThisType, $sPathToMoveTo) Local $FileDate, $file, $FDate, $iTodaysDate = _NowCalc() Local $search = FileFindFirstFile($sPath & '\' & $sThisType) ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") WinClose(@WindowsDir & "\system32\cmd.exe") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop $FDate = FileGetTime($file, 0) If @error Then ; inserted for troubleshooting ; but keep it in the code ConsoleWrite('"" (' & @ScriptLineNumber & ',0 ) error with "' & $sPath & '\' & $file & '"' & @CRLF) ContinueLoop EndIf $FileDate = $FDate[0] & "/" & $FDate[1] & "/" & $FDate[2] & " " & $FDate[3] & ":" & $FDate[4] & ":" & $FDate[5] If _DateDiff('D', $FileDate, $iTodaysDate) < 2 Then FileCopy($sPath & '\' & $file, $sPathToMoveTo & "\" & $file, 1) EndIf WEnd EndFunc ;==>myFuncForThis ..you made me code it. Didn't test but that's the idea. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
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