bt707
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,
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,
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
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
type *.txt > new.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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,
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?
ASKER
run-time error 424
object required
object required
ASKER
no i did not add a filelistbox called File1, not even sure how to do that.
Thanks,
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.
ASKER
ok I think i can get it from here, thanks for all the help.
cd c:\logfiles
ren *.* *.txt
copy *.txt Newfile.txt