Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/11/2011 in all areas

  1. rds_correia, Good - I was getting a bit worried there for a minute! Yes, you have the full file path and name with $sPath & $aAVI[0] and you can use FileMove to get it where you wish. Good luck with the GUI wrapper - as I said before, you know where we are if you run into difficulties. M23
    1 point
  2. rds_correia, SciTE is the editor which is installed with Autoit - but as you have not installed it...... You are missing a lot - the full version od SciTE4AutoIt3 which you can download here offers lots of extra goodies to help you code in AutoIt. But I believe you need to have both SciTE and AutoIt installed for it to give you full functionality. Try this version which only uses MsgBox dialogs: #include <Array.au3> #include <File.au3> #include <Date.au3> Global $sRoot = "C:surveillance" Global $aPath[5] = [4, "580001", "000", "00", "00"] Global $sCamera_ID = "323" Global $sYesterday = StringReplace(_DateAdd("D", -1, @YEAR & "/" & @MON & "/" & @MDAY), "/", "-") Global $sBefore_Yesterday = StringReplace(_DateAdd("D", -2, @YEAR & "/" & @MON & "/" & @MDAY), "/", "-") ; Find last folder $aFolder_List = _Last_Folder($aPath) ; Work backwards through the folder list For $i = $aFolder_List[0] To 1 Step -1 ; Read the list of files in this folder $aFile_List = _FileListToArray($aFolder_List[$i] & "", "*.xml", 1) ;_ArrayDisplay($aFile_List, $aFolder_List[$i]) If IsArray($aFile_List) Then If _Check_Files($aFile_List, $aFolder_List[$i]) Then ; We have reached the files from 2 days ago ExitLoop EndIf Else ; There are no files to check - this should never happen ExitLoop EndIf Next MsgBox(0, "Done", "All files from " & $sYesterday & @CRLF & "taken by camera " & $sCamera_ID & @CRLF & "have been dealt with") Func _Check_Files($aArray, $sPath) ; Clear the "day before yesterday" flag $fEnded = False For $i = $aArray[0] To 1 Step -1 ; Read the content of the file $sFile_Content = FileRead($sPath & $aArray[$i]) ; Is it the correct date $aDate = StringRegExp($sFile_Content, "(?i)(?U)starttime>(.*)x20", 3) Switch $aDate[0] Case $sYesterday ; Is it the correct camera $aCamera = StringRegExp($sFile_Content, "(?i)(?U)servicename>(.*)<", 3) If $aCamera[0] = $sCamera_ID Then ; Extract the .avi name $aAVI = StringRegExp($sFile_Content, "(?i)(?U)filename>(.*)<", 3) ; And display the data MsgBox(0, "Action needed", _ "File: " & $sPath & $aArray[$i] & @CRLF & @CRLF & _ "Avi: " & $sPath & $aAVI[0] & @CRLF & " could now be copied") EndIf Case $sBefore_Yesterday ; Set the flag $fEnded = True ; No point in going back further ExitLoop EndSwitch Next Return $fEnded EndFunc Func _Last_Folder($aPath) ; Create an array to hold the list of folders found Local $aFolders[100] = [1, $sRoot & _ArrayToString($aPath, "", 1, 4) & ""] While 1 ; Add 1 to the folder and reset to 00 if needed $aPath[4] = StringFormat("%02i", Mod($aPath[4] + 1, 100)) ; If we did reset to 00 then we need to check the level above If $aPath[4] = "00" Then ; Again we add 1 and reset to 00 if required $aPath[3] = StringFormat("%02i", Mod($aPath[3] + 1, 100)) ; And if we reset to 00 we need to check the level above If $aPath[3] = "00" Then ; Add 1 but this time we reset to 000 if required $aPath[2] = StringFormat("%03i", Mod($aPath[2] + 1, 1000)) ; And again we move up a level if the lower folder was reset If $aPath[2] = "000" Then ; If this one gets to 589999 then you need to restart - or add another level to this tree! $aPath[1] = $aPath[1] + 1 EndIf EndIf EndIf ; Now see if this path exists $sNext_Path = $sRoot & _ArrayToString($aPath, "", 1, 4) & "" If Not FileExists($sNext_Path) Then ; If the path does not exist then we return the list of folders found ReDim $aFolders[$aFolders[0] + 1] Return $aFolders Else ; The folder exists so add it to the array - resizing if necessary $aFolders[0] += 1 If UBound($aFolders) <= $aFolders[0] Then ReDim $aFolders[$aFolders[0] * 2] EndIf $aFolders[$aFolders[0]] = $sNext_Path EndIf WEnd EndFuncDo you get the results now? M23
    1 point
×
×
  • Create New...