I have a vbscript that searches log files for certain words. On each run of the script information is written to a file called letter_print_extract.txt. What I want to do is if the letter_print_extract.txt file is more than 5 days old I want to move it to a new file name and re-create it again.
To do this I'm using the code :-
'Rename existing file based on modified date of previous log file
Set SecureLogFile = objFSOLog.GetFile(strFullLogPath)
CreatedDate = SecureLogfile.DateCreated
ModifiedDate = SecureLogfile.DateLastModified
If CreatedDate <= SecureDate Then
objFSOLog.MoveFile strFullLogPath, strFullBackupPath & "_" & FormatDateToString(ModifiedDate) & ".txt"
This works fine, so I then want to re-create a new file with the same name as the one just moved.
Again this works, but the DateCreated does not show as 24th June but as 2nd June which is when the original was created.
To create the file I use
Set objFSOLog = CreateObject("Scripting.FileSystemObject")
Set LogFile = objFSOLog.OpenTextFile(strFullLogPath, ForAppending, TRUE)
The create date of this file is still 2nd June 2008.
Any ideas what I'm doing wrong. Have attached the full script for completeness.