Copy and append files into a single file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
aly1kor
Posts: 2
Joined: 03 Oct 2013 07:00

Copy and append files into a single file

#1 Post by aly1kor » 03 Oct 2013 07:42

Hello,
i need to search all files having names *.app.h in directory C:SRC and sub directory and append the content of the files into a single file, newfile.txt.

I used,
xcopy C:\SRC\*app.h newfile.txt /s

But the probelm is the files are not appended but are overwritten and hence i only hav the last file in newfile.txt ?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Copy and append files into a single file

#2 Post by foxidrive » 03 Oct 2013 08:31

Is this any good?

Code: Select all

@echo off
for /r "C:\SRC\" %%a in (*app.h) do type "%%a" >>newfile.txt

aly1kor
Posts: 2
Joined: 03 Oct 2013 07:00

Re: Copy and append files into a single file

#3 Post by aly1kor » 04 Oct 2013 02:25

Thanks a lot :) :D command works perfectly .....

zpimp
Posts: 12
Joined: 14 Jun 2013 12:58

Re: Copy and append files into a single file

#4 Post by zpimp » 07 Oct 2013 23:21

if they have the same extension (ex: txt)
copy /b *.txt all.out

Post Reply