How do I insert a date/timestamp before the contents I'm trying to append to a text file with this simple .vbs?
I'm using this script to add text to a variety of .txt's on the fly:
Const ForAppending = 8 Set objArgs = WScript.Arguments Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(objArgs(1)) Then Set objFile = objFSO.OpenTextFile(objArgs(1), ForAppending) Else Set objFile = objFSO.CreateTextFile(objArgs(1)) End If objFile.WriteLine objArgs(0) objFile.Close
So I'm sending text with the program launchy this .vbs (addln.vbs) -
("$$" c:\ideas.txt) is what the argument is if I want to send to ideas.txt for example
All I want to do is make it so I get the date and time right before whatever text I send to this text file. I don't think this would be too complicated... thanks for any pointers!
I think you should be able to do this -
objFile.WriteLine Date() & " " & Time() & " " & objArgs(0)