I posted this before but the topic is long since gone.
Ok how do I make a batch file append a txt fiile to another txt file? (Or apend text to the text file would be fine.)(Sorry if this is confusing.)
Does anyone know Batch code.
Moderators: jelco, bert_the_turtle, Chris, Icepick, Rkiver
-
- level0
- Posts: 8
- Joined: Fri Jan 11, 2002 1:28 am
- Location: Denmark
- Contact:
-
- level2
- Posts: 127
- Joined: Sat Jan 05, 2002 4:56 am
- Location: Mountain View, CA
Look into the copy command. If memory serves, you can do something like
"copy alpha + baker charlie"
and the file "charlie" will contain the contents of "alpha" followed by the contents of "baker". You'd probably need to toss in a /B if you want to concatenate binary files, because I think it'll assume ASCII otherwise.
As for appending text, DOS may support the ">>" redirection syntax. e.g.
"blah.exe > foo" will OVERWRITE foo, but
"blah.exe >>foo" should append blah's output to foo.
"copy foo + CON:" should take input from CON: (the console device) and concatenate it to "foo".
But it's been a while, and I'm on a 'nix, so test using toy files before you try with anything important.
"copy alpha + baker charlie"
and the file "charlie" will contain the contents of "alpha" followed by the contents of "baker". You'd probably need to toss in a /B if you want to concatenate binary files, because I think it'll assume ASCII otherwise.
As for appending text, DOS may support the ">>" redirection syntax. e.g.
"blah.exe > foo" will OVERWRITE foo, but
"blah.exe >>foo" should append blah's output to foo.
"copy foo + CON:" should take input from CON: (the console device) and concatenate it to "foo".
But it's been a while, and I'm on a 'nix, so test using toy files before you try with anything important.
"I tell you three times..."
Ok Here is the code. I have two different ideas.
Author:On_fire
@echo off
cd data
h1.txt >> output.txt
:1
choice /c:yn texta
if errorlevel is 1 then goto texta
:2
choice /c:yn textb
if errorlevel is 1 then goto textb
:3
exit
:texta
texta.txt >> output.txt
goto 2
:textb
textb.txt >> output.txt
goto 3
Author:On_fire
@echo off
cd data
h1.txt >> output.txt
choice /c:yn texta
if errorlevel is 1 then goto texta.txt >> output.txt
choice /c:yn textb
if errorlevel is 1 then goto textb.txt >> output.txt
exit
I thought I had the code right but it is not working.
All the text files and the output.txt file are in a data folder. Anyone know why this won't work?
(Edited by On fire at 9:45 am on Sep. 6, 2002)
(Edited by On fire at 10:15 am on Sep. 6, 2002)
Author:On_fire
@echo off
cd data
h1.txt >> output.txt
:1
choice /c:yn texta
if errorlevel is 1 then goto texta
:2
choice /c:yn textb
if errorlevel is 1 then goto textb
:3
exit
:texta
texta.txt >> output.txt
goto 2
:textb
textb.txt >> output.txt
goto 3
Author:On_fire
@echo off
cd data
h1.txt >> output.txt
choice /c:yn texta
if errorlevel is 1 then goto texta.txt >> output.txt
choice /c:yn textb
if errorlevel is 1 then goto textb.txt >> output.txt
exit
I thought I had the code right but it is not working.
All the text files and the output.txt file are in a data folder. Anyone know why this won't work?
(Edited by On fire at 9:45 am on Sep. 6, 2002)
(Edited by On fire at 10:15 am on Sep. 6, 2002)
People that swear Don't know any more intelegent ways to express themself.
-
- level0
- Posts: 3
- Joined: Wed Aug 28, 2002 4:01 pm
- Location: Riga
-
- level5
- Posts: 11553
- Joined: Wed Jul 10, 2002 7:44 pm
- Location: Nashville, TN
- Contact:
Here is a file that does what you want, I think. I have not tested it. :)
http://www.tl.infi.net/~wtnewton/batch/cram.htm
(Edited by Stewsburntmonkey at 2:19 pm on Sep. 6, 2002)
http://www.tl.infi.net/~wtnewton/batch/cram.htm
(Edited by Stewsburntmonkey at 2:19 pm on Sep. 6, 2002)
Who is online
Users browsing this forum: No registered users and 20 guests