Link to home
Start Free TrialLog in
Avatar of bt707
bt707Flag for United States of America

asked on

Combine text files to a single file

I have a lot of log files in a folder and would like to be able to rename the (.log) to (.txt) and
then combine all of them into one txt file.

I can use the dos command CD c:\logfiles ren *.* *.txt     to rename the all the ext's but how can i run a script that will combine all the files into one.

Thanks,
Avatar of vinnyd79
vinnyd79

Have you tried using copy?

cd c:\logfiles
ren *.* *.txt
copy *.txt Newfile.txt
You can call it through vb using Shell:

Private Sub Command1_Click()
ChDrive "C:\"
ChDir "C:\logfiles"
Shell Environ("Comspec") & " /c copy *.* C:\NewFile.txt", vbHide
End Sub
You can also type this on the command line

type *.txt > new.txt
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bt707

ASKER

I'm getting a error, when i click on debug it is telling me that the error is in this line

File1.Path = "C:\logfiles"

the files are in this folder, not sure what's going on.

Thanks,
Whats the error?
Did you add a Filelistbox called File1?
Avatar of bt707

ASKER

run-time error 424
object required
Avatar of bt707

ASKER

no i did not add a filelistbox called File1, not even sure how to do that.

Thanks,
Just add a Filelistbox to your form.It should be in your vb toolbox on the left.It looks like a document icon.
On the components tab, there is a control called FileListBox, just add it to your form and name it File1.
You might also want to keep this control invisible at runtime. Depends on your requirements.
Avatar of bt707

ASKER

ok I think i can get it from here, thanks for all the help.