batch file to copy text to another file

Microsoft Windows xp professional w/serv...
August 4, 2010 at 15:21:50
Specs: XP
Hi, I'm trying to write a batch file that will copy all text files from a directory and append them to a .txt file. So far I have:

type *.txt >>C:\directory\all.txt

This works but it doesn't return in the new text file after appending each text file.

e.g. new file reads:
textfile1contenttextfile2contenttextfile3content

I would like the new file to read:
textfile1content
textfile2content
textfile3content

Any help is appreciated


See More: batch file to copy text to another file

Report •

#1
August 4, 2010 at 17:01:13
copy /B *.txt c:\directory\all.txt

Report •

#2
August 4, 2010 at 17:42:28
Thanks for the response but it is still outputting:

textfile1contenttextfile2contenttextfile3content


Report •

#3
August 6, 2010 at 07:38:28
@echo Off
@For %%a in ("*.txt") do echo   >> %%a
type *.txt >> all.txt

Report •

Related Solutions

#4
August 6, 2010 at 07:40:19
Hope this helps. I tried it with the example you gave. This does alter the file! If that is not allowed, then we can modify it to create a copy of the files and alter those files and then delete them.

Report •

#5
August 6, 2010 at 07:52:27
@echo Off
@For %%a in ("*.txt") do copy %%a %%a_COPY.txt
@For %%a in ("*.txt_COPY.txt") do echo   >> %%a_COPY.txt
type *.txt_COPY.txt >> all.txt
@for %%a in ("*.txt_COPY.txt") do del %%a

here is the modified version just in case! This works, but may not be the cleanest code.


Report •

#6
August 6, 2010 at 08:59:55
for %%a in (*.txt) do @(type %%a &echo.) >> out
ren out out.txt


Report •

#7
August 6, 2010 at 11:34:35
thanks for the help guys, got it working!

Report •

Ask Question