How to? redirect a bunch of loop

Nov 8, 2015
27
1
How one can redirect the whole do loop process in once in batch scrip, not in a line with command separator character and does not use iterated redirection i.e. using '>>' within loop body.

do i=1 to 9
echo Page %i
enddo

... then how to redirect it to text file e.g ' >a ' once for all output above ??
 
May 20, 2008
11,400
99
Syracuse, NY, USA
This seems to work. I don't know how robust it is.
Code:
v:\> type reddo.btm
> reddo.txt do i=1 to 3
echo %i
enddo

v:\> reddo.btm

v:\> type reddo.txt
1
2
3
 
Nov 8, 2015
27
1
I'll try it and do with trial and error.. Thanks so much and God bless you.. aameen
 

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
This may work also. It's basically the same command:
Code:
do i=1 to 3 > reddo.txt
I have not tried it though.
 

rps

Jul 6, 2008
436
6
This may work also. It's basically the same command:
Code:
do i=1 to 3 > reddo.txt
I have not tried it though.
This works for me.
Code:
C:\JPSoft>(do i=1 to 3 (echo %i))
1
2
3
C:\JPSoft>(do i=1 to 3 (echo %i)) >! reddo.txt
C:\JPSoft>type reddo.txt
1
2
3
Here it is as a simple btm:
Code:
C:\JPSoft>type reddo.btm
: reddo.btm
do i=1 to 3
echo %i
enddo
C:\JPSoft>reddo.btm >! reddo.txt
C:\JPSoft>type reddo.txt
1
2
3
The >! just over rights any existing reddo.txt.
 
Similar threads
Thread starter Title Forum Replies Date
JohnQSmith WAD DO and escaped redirect characters Support 6
J Can you redirect output to printer device with echo? Support 1
nickles Redirect bug? Support 4
E Redirect output from "start"-ed console Support 5
D Start program without waiting and redirect output Support 6
C redirect with TCMD 8.02 Support 4
samintz How to? Abort on error DO loop Support 10
D How to use multi-line DO to loop through first level directory names Support 5
vefatica ON ERROR terminates DO loop. Support 0
Dick Johnson for ... do loop "wrap around" Support 11
vefatica Modifying a counted DO loop's counter? Support 1
Z [dos] into - for loop - the bp is not hit Support 5
vefatica Piping the output of a DO loop. Support 4
rps For loop internal %_for_files variable? Support 2
D What is the limit on the compound statement length within ( ) of a FOR-loop? Support 5
old coot Proper use of ON ERRORMSG inside a DO WHILE loop? Support 3
H EndLocal in DO Loop Support 2
Mike Hall Unexpected "Variable loop" in IF condition Support 10
C FOR loop with nested IF / IFF Support 9
D Strange issue with FOR loop Support 15
nickles WAD Variable name gets changed within FOR loop Support 2
M tcmd crashes in this recursive "for /f" loop Support 4
G Fixed Slow FOR loop Support 2
S WAD %_do_errors does not report errors when loop control variable type is not directory entry Support 1
mikea 'Loop' on closing TC Support 6
Roedy Loop anomaly Support 6
R nested for loop question Support 3
P Need to use a regex in a "for" loop. Support 54

Similar threads