From: J. P. Gilliver (John) on
I know one way to join files: in a command box,

copy /b filea+fileb filec

.. However, if filea is huge, this takes a noticeable time, because the
entirety of filea is copied to filec (followed by fileb, obviously).

I know with text files, you can just append things to another file - e.
g.

dir >> filea

will I think append a directory listing to filea, or

type fileb >> filea

will append fileb to filea - but only if it's a text file.

Anyone know how to concatenate arbitrary files, without involving a
third file?
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G.5AL-IS-P--Ch++(p)Ar(a)T0H+Sh0!:`)DNAf
** http://www.soft255.demon.co.uk/G6JPG-PC/JPGminPC.htm for ludicrously
outdated thoughts on PCs. **

Mathematics is the language with which God has written the universe. -Galileo
Galilei, physicist and astronomer (1564-1642)
From: Anteaus on
This task is probably a little beyond batch language. I would suggest trying
AutoIt's FileWrite command, which can append data to an existing file.

http://autoitscript.com

"J. P. Gilliver (John)" wrote:

> Mathematics is the language with which God has written the universe. -Galileo
> Galilei, physicist and astronomer (1564-1642)

A surprising example to choose, in view of what the Inquisition did to
Galileo for the simple act of publishing his understandings of our solar
system.

http://www.pbs.org/wgbh/nova/galileo/life.html

It is possible that if Galileo had not done so, science would have remained
the province of underground 'heretics' and that today there would be no
computers, nothing of modern tech, for that matter. Instead we'd all be
living like Harrid and Sallis of Ver Ager, in an enforced state of
mediaevalism designed to secure the power of the ecclesiastical rulers.

We all owe a great deal to Galileo, not just as a scientist but as a
proponent of free speech and human-rights. Today, whenever you speak your
mind freely about the nature of the universe... or about anything - think of
Galileo.

From: J. P. Gilliver (John) on
In message <1DAE1A34-9992-41EB-AD14-45D34566D9FC(a)microsoft.com>, Anteaus
<Anteaus(a)discussions.microsoft.com> writes:
>This task is probably a little beyond batch language. I would suggest trying
>AutoIt's FileWrite command, which can append data to an existing file.
>
>http://autoitscript.com

Thanks for that; I suspect it's too complicated for the person I had in
mind.

I have a friend who - for reasons we needn't go into here - concatenates
files (usually video files), by the simple expedient of

copy /b filea+fileb filec

which does the trick (and more quickly than loading them into a video
editing prog. - he knows what he's doing); however, I was watching him
do it once when filea was much bigger than the others (there were
actually several), and it seemed a pity to have to wait for the system
to copy the huge filea, when all he wanted was the others stuck onto the
end of it (he didn't have any need for filea to be retained unmodified).
Especially when I know that the ">>" operator works for text files - as
in

dir >> filez.txt

will tag the output of the dir command onto the end of filez.txt (much
as dir > filez.txt will create filez.txt and then put the dir output
into it).

I found/find it odd that this facility works, but only for text files;
the mechanism is already there, obviously, but I can't see any way round
it. Ho hum.
>
>"J. P. Gilliver (John)" wrote:
>
>> Mathematics is the language with which God has written the universe. -Galileo
>> Galilei, physicist and astronomer (1564-1642)
>
>A surprising example to choose, in view of what the Inquisition did to
>Galileo for the simple act of publishing his understandings of our solar
>system.

Hmm, the choice of that quote had nothing to do with the subject of the
thread - they're picked at random (by an ancient DOS utility called
Tomsystems Quote!) from a file of such that I have accumulated over the
years. If you mean it's odd of itself, I just thought it was a pleasing
thought; Galileo himself, I suspect, either doubted the existence of God
and just thought it was a clever thing to say, or didn't think the
Inquisition represented God.
[]
>It is possible that if Galileo had not done so, science would have remained
>the province of underground 'heretics' and that today there would be no
>computers, nothing of modern tech, for that matter. Instead we'd all be
>living like Harrid and Sallis of Ver Ager, in an enforced state of
>mediaevalism designed to secure the power of the ecclesiastical rulers.

One fears that this is at least a consequence - if not consciously the
actual aim - of some of the more extreme extremists in some countries.
(Even including Christians - some of them are very against research/work
in certain areas. But that is getting way off-topic, especially for a
newusers 'group.)
>
>We all owe a great deal to Galileo, not just as a scientist but as a
>proponent of free speech and human-rights. Today, whenever you speak your
>mind freely about the nature of the universe... or about anything - think of
>Galileo.
>
Indeed. (And others, of course.)
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G.5AL-IS-P--Ch++(p)Ar(a)T0H+Sh0!:`)DNAf
** http://www.soft255.demon.co.uk/G6JPG-PC/JPGminPC.htm for ludicrously
outdated thoughts on PCs. **

"I'm a self-made man, but I think if I had to do it over again, I'd call in
someone else." - Roland Young
From: Anteaus on
Quickly knocked this together and it seems to do the trick:
*****************************
; concat.au3 - compile to concat.exe

if $cmdLine[0]<>2 then
msgbox(32,"File Concatenator","Usage: concat existingfile additionaldata")
exit
endif

; Get the files to merge from the commandline:
;(Alternatively you could hardcode them here, or use an .ini)
$mainFile=$cmdLine[1]
$addFile=$cmdLine[2]

; Open files, and get handles to file buffers
; 17=binary write mode, 16=binary read mode

$hdlMain = FileOpen($mainFile,17)
if @error then
msgbox(64,"Error","Cannot open target file for writing")
exit
endif

$hdlAdd = FileOpen($addFile,16)
if @error then
msgbox(64,"Error","Cannot open source file for reading")
exit
endif

; Do the business:
$data=FileRead($hdlAdd)
FileWrite($hdlMain,$data)

; Close-off files (Not essential in Autoit, but good general coding practice)
FileClose($hdlAdd)
FileClose($hdlMain)

exit

***************************************

Compile with the Autoit compiler, available from http://autoitscript.com

Note that it works by loading the entire contents of the additional file
into RAM. This works well for files of reasonable size, but might hit issues
if the second file is larger than the machine's free RAM. In that case it
might be necessary to segment the file, which does get a trifle more
complicated.

Lines beginning ; are comments.

"J. P. Gilliver (John)" wrote:

> Thanks for that; I suspect it's too complicated for the person I had in
> mind.
>

From: Richard on
> "J. P. Gilliver (John)" <G6JPG(a)soft255.demon.co.uk> wrote in message
> news:Ta5FQGaKTB5KFwoY(a)soft255.demon.co.uk...
> I know one way to join files: in a command box,
>
> copy /b filea+fileb filec
>
> . However, if filea is huge, this takes a noticeable time, because
> the entirety of filea is copied to filec (followed by fileb,
> obviously). I know with text files, you can just append things to
> another file - e. g.
>
> dir >> filea
>
> will I think append a directory listing to filea, or
>
> type fileb >> filea
>
> will append fileb to filea - but only if it's a text file.
>
> Anyone know how to concatenate arbitrary files, without involving a third
> file?

To append fileB to fileA:

copy /b fileA+fileB fileA

FWIW. --Richard