Question:
How can I group several TXT files into a single one?
Solution:
To do so, you must create a script to read each file’s content and store it in a variable. Then, you must pass the variable’s value to the general file. For example:
dim content, NFiles, aux, aux1, fso, f
Const ForReading = 1, ForWriting = 2
content = “”
‘number of files:
NFiles = 4
‘reads each file
for i=1 to NFiles
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set f = fso.OpenTextFile(“file”& i & “.txt”, ForReading)
content = content & f.ReadAll & vbNewLine & “**********************” & vbNewLine
next
‘Creates the “General File” (if it already exists, erase the file)
Set aux = CreateObject(“Scripting.FileSystemObject”)
Set aux1 = aux.CreateTextFile(“generalfile.txt”, True)
aux1.Close
‘Writes all content in the GeneralFile
Set aux = CreateObject(“Scripting.FileSystemObject”)
Set aux1 = aux.OpenTextFile(“generalfile.txt”,8)
aux1.WriteLine content
aux1.Close
file1.txt
file 2.txt
file 3.txt
…For more details, check the attached sample application developed with E3 version 3.2 build 260.
Attachments: