Jump to content

Delete date and time in the txt files


agent47
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...