You are not logged in.

#1 05 Mar 2015 08:49

motalab
New Member
Registered: 05 Mar 2015
Posts: 2

How to Concatenate two files writing batch script

I want add two files writing a batch script. In Linux we can write  like : cat file1 file2 > file3. I want to do similar thing in windows batch script. please help me.

Offline

#2 05 Mar 2015 14:33

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 205

Re: How to Concatenate two files writing batch script

The batch equivalent of cat is type. You can use it the same way, although type file1 file2 output looks like

file1

<contents of file1>

file2

<contents of file2>

If you don't want headers, you can do

type file1 > file3
type file2 >> file3

just like in Linux.

Offline

#3 06 Mar 2015 03:49

Aacini
Member
Registered: 05 Dec 2012
Posts: 149

Re: How to Concatenate two files writing batch script

... or:

(type file1 & type file2) > file3

You may also develop your own cat.bat file, like this one:

@for %%a in (%*) do @type %%a

... and then do:

cat file1 file2 > file3

Offline

Board footer

Powered by