SeattleSteve Posted October 12, 2009 Share Posted October 12, 2009 (edited) I have a simple script that tries to rename a file when it's Create Date is different than today's date. This is so we can save a daily log file off to the side and then create a new empty one. The 'active' log file is called "GAK_Capture.log" and the renamed one has the date imbedded in the name (i.e. "GAK_Capture_20091012.log"). We are running AutoItV3. We try to use the FileMove function call to rename/move the file and then we issue a FileOpen to create the new active file. What we've noticed is that when all of this occurs within the scope of one script then the 'new' file actually inherits the Create Date of the original file. Is this a bug in AutoItV3? Can anyone tell me of any other way to do this outside of running two separate scripts? Here's our simple script: ***************************************** $GalaxyPath = "C:\Program Files\Gateway Ticketing Systems\Galaxy\" $GakLog = $GalaxyPath & "GAK_Capture.log" $Today = @YEAR & @MON & @MDAY if FileExists ($Gaklog) Then $FTime = FileGetTime ($Gaklog, 1) If ($Today <> $FTime[0] & $FTime[1] & $FTime[2]) Then FileMove ($GakLog, $GalaxyPath & "Logs\Gak_Capture_" & $Today & ".log") EndIf EndIf if Not FileExists($GakLog) Then $file = FileOpen ($GakLog, 1) FileClose ($file) EndIf ***************************************** We've confirmed that after a successful FileMove the second "If Not FileExists" processes properly and we see a new, empty file being created. Unfortunately it still has the Create Date of the original file...over and over and over. Any and all feedback/advice is greatly appreciated. Steve Edited October 12, 2009 by SeattleSteve Link to comment Share on other sites More sharing options...
botanic Posted October 13, 2009 Share Posted October 13, 2009 (edited) try this $GalaxyPath = "C:\Program Files\Gateway Ticketing Systems\Galaxy\" $GakLog = $GalaxyPath & "GAK_Capture.log" $Today = @YEAR & @MON & @MDAY if FileExists ($Gaklog) Then $FTime = FileGetTime ($Gaklog, 1) If ($Today <> $FTime[0] & $FTime[1] & $FTime[2]) Then FileMove ($GakLog, $GalaxyPath & "Logs\Gak_Capture_" & $Today & ".log") $file = FileOpen($GalaxyPath & "GAK_Capture.log", 1) FileClose ($file) EndIf EndIf also if FileMove returns a 0 that means that the file cant be moved so its just copying it instaed Edited October 13, 2009 by botanic Link to comment Share on other sites More sharing options...
SeattleSteve Posted October 13, 2009 Author Share Posted October 13, 2009 I tried your suggestion, to no avail. I even changed the reference to $GakLog in the FileMove to be the concatenation of the $GalaxyPath and the quoted string, like your recommended change in the FileOpen command. It also turns out that FileMove is returning a value of 1 so that it is truly moving the file. I can put a sleep in between the steps and watch the file disappear; when the 'new' file shows up it still has the Create Date of the original file. 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