Computing.Net > Forums > Disk Operating System > Creating a batch file to append to a text file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Creating a batch file to append to a text file

Reply to Message Icon

Name: Dale Cooper
Date: June 12, 2000 at 03:25:04 Pacific
Comment:

Hi,

I need to create a batch file that will copy two text files from a server drive and append them to a history text file. I think I need to use the COPY command with + to append a file, but I just can't get it to work. Can anyone tell me exactly what the syntax should be? The two files that need to be copied are called 'adlabels.txt' and 'aclabels.txt', and the history file is called 'labels.hst'. The two text files are basically print jobs, which are deleted once they are completed. New files are then generated for the next print job with the same names - these two new files would then also need to be added to the history file, which I am hoping the batch file will do.

Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: browser
Date: June 12, 2000 at 09:34:51 Pacific
Reply:

The COPY command will refuse to copy a program on top of itself, so there needs to be some amount of re-naming. I have not tested the following, but it should work.

cd x:\xxxx\xxxx (change to directory)
rename labels.hst labels.$$$
copy labels.$$$+adlabels.txt+aclabels.txt labels.hst


0

Response Number 2
Name: browser
Date: June 12, 2000 at 12:00:27 Pacific
Reply:

Sorry, but I omitted the last line.

del labels.$$$


0

Response Number 3
Name: World Library
Date: June 12, 2000 at 14:05:22 Pacific
Reply:

Hi,
Instead of using "copy" try "type".

example:
cls
@echo off
type adlabels.txt >>label.hst
type aclabel.txt >>label.hst

Note: 1 > will overwrite.
2 >> appends....adds

To use copy and type

copy adlabels.txt + aclabels.txt label.txt
type label.txt >>label.hst
*************snip and paste***********
cls
@echo off
copy adlabels.txt + aclabels.txt label.txt
type label.txt >>label.hst
:end
cls

Hope this is of help. The copy command is not always the best way to copy.......hmmmm.

Peace Goodwill and Happy Computing

World Library


0

Response Number 4
Name: Dale Cooper
Date: June 13, 2000 at 00:38:08 Pacific
Reply:

Many thanks to the both of you for the help - I now have a working batch file that does exactly what I want!


0
Reply to Message Icon

Related Posts

See More


Download DOS 6.2 Compaq laptop



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Creating a batch file to append to a text file

Is there any ways to declare a variable inside a batch file ?? www.computing.net/answers/dos/is-there-any-ways-to-declare-a-variable-inside-a-batch-file-/3377.html

checking a file date to execute a batch file www.computing.net/answers/dos/checking-a-file-date-to-execute-a-batch-file/1909.html

Pass %%a in FOR as param to batch file www.computing.net/answers/dos/pass-a-in-for-as-param-to-batch-file/10730.html