hidden hit counter
Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How do you tag one file onto the end of another?

 
   Soft32 Home -> Windows -> New Users RSS
Next:  Infinitely Recursive Directory Problem  
Author Message
"J. P. Gilliver

External


Since: Jun 08, 2009
Posts: 19



(Msg. 1) Posted: Sun Oct 25, 2009 5:20 am
Post subject: How do you tag one file onto the end of another?
Archived from groups: microsoft>public>windowsxp>newusers (more info?)

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@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)
Back to top
Login to vote
Anteaus

External


Since: Aug 08, 2007
Posts: 152



(Msg. 2) Posted: Sun Nov 01, 2009 2:07 am
Post subject: RE: How do you tag one file onto the end of another? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
Back to top
Login to vote
"J. P. Gilliver

External


Since: Jun 08, 2009
Posts: 19



(Msg. 3) Posted: Sun Nov 01, 2009 9:20 am
Post subject: Re: How do you tag one file onto the end of another? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In message <1DAE1A34-9992-41EB-AD14-45D34566D9FC RemoveThis @microsoft.com>, Anteaus
<Anteaus RemoveThis @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@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
Back to top
Login to vote
Anteaus

External


Since: Aug 08, 2007
Posts: 152



(Msg. 4) Posted: Mon Nov 02, 2009 10:59 am
Post subject: Re: How do you tag one file onto the end of another? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.
>
Back to top
Login to vote
Richard

External


Since: May 13, 2009
Posts: 47



(Msg. 5) Posted: Sat Nov 07, 2009 10:56 am
Post subject: Re: How do you tag one file onto the end of another? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

> "J. P. Gilliver (John)" <G6JPG DeleteThis @soft255.demon.co.uk> wrote in message
> news:Ta5FQGaKTB5KFwoY@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
Back to top
Login to vote
"J. P. Gilliver

External


Since: Jun 08, 2009
Posts: 19



(Msg. 6) Posted: Sat Nov 07, 2009 7:20 pm
Post subject: Re: How do you tag one file onto the end of another? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In message <OaWOX88XKHA.1372.RemoveThis@TK2MSFTNGP02.phx.gbl>, Richard
<richard.RemoveThis@avbtab.org> writes:
>
>> "J. P. Gilliver (John)" <G6JPG.RemoveThis@soft255.demon.co.uk> wrote in message
>> news:Ta5FQGaKTB5KFwoY@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
>
>
>
Won't that still go through the motions of copying every byte of fileA,
even if it's putting the results back in the same place?
--
J. P. Gilliver. UMRA: 1960/<1985 MB++G.5AL-IS-P--Ch++(p)Ar@T0H+Sh0!:`)DNAf
** http://www.soft255.demon.co.uk/G6JPG-PC/JPGminPC.htm for ludicrously
outdated thoughts on PCs. **

Archduke Ferdinand found alive - First World War a mistake!
Back to top
Login to vote
Jim

External


Since: Aug 01, 2004
Posts: 12



(Msg. 7) Posted: Sun Nov 08, 2009 11:20 am
Post subject: Re: How do you tag one file onto the end of another? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I've been following this correspondence with interest, since, for a reason
which escapes me now, I used to append one text file to another back in the
days of DOS.

However, one thing escapes me : apart from text files (under which term I
include program source code and anything else in text), what would be the
point of appending one file to another?

Jim
Back to top
Login to vote
Richard

External


Since: May 13, 2009
Posts: 47



(Msg. 8) Posted: Mon Nov 09, 2009 11:20 am
Post subject: Re: How do you tag one file onto the end of another? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

>>> "J. P. Gilliver (John)" <G6JPG DeleteThis @soft255.demon.co.uk> wrote in message
>>> news:Ta5FQGaKTB5KFwoY@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?
>>
>> In message <OaWOX88XKHA.1372 DeleteThis @TK2MSFTNGP02.phx.gbl>, Richard
>> <richard DeleteThis @avbtab.org> writes:
>>
>> To append fileB to fileA:
>>
>> copy /b fileA+fileB fileA
>>
>> FWIW. --Richard
>>
>>
>>

> "J. P. Gilliver (John)" <G6JPG DeleteThis @soft255.demon.co.uk> wrote in message
> news:H+xAZsK6Nh9KFwI$@soft255.demon.co.uk...
>
> Won't that still go through the motions of copying every byte of fileA,
> even if it's putting the results back in the same place?

Hi again John,

(Actually, I used such small test files it was too fast to tell. Smile

Here's the output of my 2 tests:
C:\>copy /a test1.txt+test2.txt test1.txt
test1.txt
test2.txt
1 file(s) copied.

C:\>type test1.txt
This is test1...
This is test2...

C:\>copy /a test1.txt+test2.txt+test3.txt test1.txt
test1.txt
test2.txt
test3.txt
1 file(s) copied.

C:\>type test1.txt
This is test1...
This is test2...
This is test2...
This is test3...

Note that it says only "1 file(s) copied."

(We need bigger guns... Smile

Made a copy of a 120MB exe file as trial1.exe (took more than 2 seconds)
Made a copy of a 5MB exe file as trial2.exe (took less than a second)
C:\>copy /b trial1.exe+trial2.exe trial1.exe

took less than a second to append 5MB to 120MB file to get 125MB
Deleted both trial*.exe files.

Copied 120MB exe file as trial1.exe again
Copied 5MB exe file as trial2.exe again
C:\>copy /b trial2.exe+trial1.exe trial2.exe

took more than 2 seconds to append 120MB file to 5MB file to get 125MB
Deleted both trial*.exe files.

That proves that when appending the small to the large file, the large file
was not re-copied into itself, but the 2nd file was only added on the end.

HTH. (Hope This Helps. Smile
--Richard

- - -
Special Veteran's Day Remembrance
http://www.avbtab.org/rc/veterans.htm
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Need File - Can anyone tell me where I can get this File \windows\system32\config\system , that is missing in my Girlfriend..

Need File - Can anyone tell me where I can get this File \windows\system32\config\system , that is missing in my Girlfriend..

zip a file - i need to send either send an excel workbook or copy it to a floppy. It is 32KB in size. Q1. if i zip it will it fit..

open file - Open a file. I see things in reverse order. How do I fix this to default to the correct order?

File versions. - I have just noticed that my virus scanner tells me that some files have 'changed' (but are not virused) and looking bac...

OPENING A FILE - This may be simple for some,but I need help. Ihave installed XP over Windows 98 2ed all my old files are there but I..
       Soft32 Home -> Windows -> New Users All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
  Windows
 Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]