agent47 Posted December 16, 2009 Share Posted December 16, 2009 Hi i am new to Autoit so please help me with the below code $time = @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC $TextFileName = "C:\log.txt" $FileContents = FileRead($TextFileName) If $FileContents = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $FileContents =StringReplace( $FileContents ,$time, "",0 ) FileDelete($TextFileName) FileWrite($TextFileName,$FileContents) FileClose($FileContents) Here is my problem I have an log which has random date and time in the log so i want to remove only date and time from the log so i have tried the above code but i am not able to remove,Kindly anyone verifies the above code and provide me feedback. Contents in the log: 2009-11-15 06:03:20 absolute beginner about Programming in General and I am starting to learn programming 2009-11-15 06:03:21 path of the folder is and library functions are So i want only to remove above year,date and time so plese help me with it. Link to comment Share on other sites More sharing options...
99ojo Posted December 16, 2009 Share Posted December 16, 2009 Hi, try this: #Include <File.au3> $TextFileName = "C:\log.txt" _FileReadToArray($TextFileName, $aArray) For $i = 1 to UBound ($aArray) - 1 $aArray [$i] = StringTrimLeft ($aArray [$i], 20) Next _FileWriteFromArray ($TextFileName, $aArray, 1) ;-)) Stefan Link to comment Share on other sites More sharing options...
agent47 Posted December 16, 2009 Author Share Posted December 16, 2009 Hi, try this: #Include <File.au3> $TextFileName = "C:\log.txt" _FileReadToArray($TextFileName, $aArray) For $i = 1 to UBound ($aArray) - 1 $aArray [$i] = StringTrimLeft ($aArray [$i], 20) Next _FileWriteFromArray ($TextFileName, $aArray, 1) ;-)) Stefan Hey thnx a lot i got it!! 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