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

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Creating a batch file to append to a text file

Reply to Message Icon

Original Message
Name: Dale Cooper
Date: June 12, 2000 at 03:25:04 Pacific
Subject: Creating a batch file to append to a text file
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.


Report Offensive Message For Removal


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

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


Report Offensive Follow Up For Removal

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

Sorry, but I omitted the last line.

del labels.$$$


Report Offensive Follow Up For Removal

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

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


Report Offensive Follow Up For Removal

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

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


Report Offensive Follow Up For Removal







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








Do you have a Desktop Computer anymore?

No
Yes, but only at work
Yes, but its rarely used
Yes, and its a workhorse


View Results

Poll Finishes Today.
Discuss in The Lounge
Poll History




Data Recovery Software