Page 1 of 1

Copy and append files into a single file

Posted: 03 Oct 2013 07:42
by aly1kor
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 ?

Re: Copy and append files into a single file

Posted: 03 Oct 2013 08:31
by foxidrive
Is this any good?

Code: Select all

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

Re: Copy and append files into a single file

Posted: 04 Oct 2013 02:25
by aly1kor
Thanks a lot :) :D command works perfectly .....

Re: Copy and append files into a single file

Posted: 07 Oct 2013 23:21
by zpimp
if they have the same extension (ex: txt)
copy /b *.txt all.out