开发者

I have two text files, I need to merge the two with a date stamp using VBscript

I have two .txt files; I have written a VBscript to identify the two last modified files. The code echoes the two modified files separately. I need to merg开发者_运维知识库e these two modified files and provide a different name with a date stamp.

Example:

txt1.txt
txt2.txt

After merge:

txt09022011.txt


Assuming you just want to dump the contents of each text file in sequence into a new text file:

Dim strInputPath1, strInputPath2, strOutputPath
Dim txsInput1, txsInput2, txsOutput
Dim FSO

Set FSO = CreateObject("Scripting.FileSystemObject")

strInputPath1 = "C:\txt1.txt"
strInputPath2 = "C:\txt2.txt"
strOutputPath = "C:\txt" & Format(Now, "ddmmyyyy") & ".txt" 
' For the timestamp I use Now (today's date). Can also choose some other date. 

Set txsInput1 = FSO.OpenTextFile(strInputPath1, 1)
Set txsInput2 = FSO.OpenTextFile(strInputPath2, 1)
Set txsOutput = FSO.CreateTextFile(strOutputPath)

txsOutput.Write txsInput1.ReadAll
txsOutput.Write txsInput2.ReadAll

txsInput1.Close
txsInput2.Close
txsOutput.Close
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜