batch file wont write %Q% to a text file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
BatMaster
Posts: 28
Joined: 22 Dec 2010 12:53

batch file wont write %Q% to a text file

#1 Post by BatMaster » 26 Sep 2011 12:22

the batch file wont write the variable Q to a text file

Code: Select all

@echo off
:start
set "Q"="1"
:start2
set "Q"="Q + 1"
>>text.txt echo set /p line%Q%=
goto start2
pause

please help

Exouxas
Posts: 34
Joined: 01 Sep 2011 12:52

Re: batch file wont write %Q% to a text file

#2 Post by Exouxas » 26 Sep 2011 13:14

When using math with the 'set' command, you do 'set /a'
and remove all the " thingys
Also, why do you have the :start when you dont use it?

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: batch file wont write %Q% to a text file

#3 Post by Ranguna173 » 26 Sep 2011 15:50

BatMaster wrote:

Code: Select all

>>text.txt echo set /p line%Q%=


That is a weird code...
For you case, here is the one I use:

%Q%>>text.txt

BatMaster wrote:

Code: Select all

:start2
set "Q"="Q + 1"
>>text.txt echo set /p line%Q%=
goto start2
pause



Why did you put the "pause" at the end?

It's a loop "goto start2"

Post Reply