China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 16:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Regarding the usage of echo: The batch file generated by batch processing always lacks a percent sign View 1,478 Replies 8
Original Poster Posted 2008-09-26 00:36 ·  中国 陕西 西安 电信
新手上路
Credits 18
Posts 8
Joined 2008-09-26 00:07
17-year member
UID 126652
Gender Male
Status Offline
echo for /L %%i in (1 1 10) do start cmd>>test.bat

I want to put for /L %%i in (1 1 10) do start cmd into test.bat, but actually what is written into test.txt is for /L %i in (1 1 10) do start cmd, always missing a %, please give advice, I'm a newbie.

───────────────── Moderation Record ─────────────────
Performed by: HAT
Operation: Added search keywords to the post title on 2008-10-10; added code tags to the code
Explanation: The original title "About the usage of echo" was not conducive to forum search
Punishment: No score punishment due to being a forum newbie
Tip: It is suggested to read the following posts
{1415}The Wisdom of Asking Questions
{7326}Must-read for Forum Newcomers, Basic Code of Conduct for Everyone
{22703}Please Don't Be an Impatient Person
{32667}Those Who Can't Even Write a Clear Title, Wake Up
{32825}This Board Strictly Rectifies Poor-quality Posts
───────────────── Moderation Record ─────────────────


[ Last edited by HAT on 2008-10-10 at 05:43 ]
Floor 2 Posted 2008-09-26 01:01 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
Strange, this problem seems very simple. According to my idea, it should only generate one %, but I tried it in CMD and found my two %, which is exactly the result you want. What version of Windows do you have?
Floor 3 Posted 2008-09-26 01:12 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
Floor 4 Posted 2008-09-26 01:13 ·  中国 上海 电信
金牌会员
★★★★
Credits 4,639
Posts 2,239
Joined 2005-01-30 00:00
21-year member
UID 35785
Gender Male
Status Offline
Do you use 4DOS / 4NT / Take Command? Such a result matches my expectation.
Floor 5 Posted 2008-09-26 01:32 ·  中国 广东 韶关 电信
高级用户
★★★
CMD感染者
Credits 691
Posts 383
Joined 2008-05-23 00:38
18-year member
UID 119451
Gender Male
Status Offline
In CMD, it's %%i. In batch processing, it's %%%%i
Floor 6 Posted 2008-10-09 23:29 ·  中国 陕西 西安 电信
新手上路
Credits 18
Posts 8
Joined 2008-09-26 00:07
17-year member
UID 126652
Gender Male
Status Offline
Could it be a problem with my Windows version? I'll try it tomorrow %%%%i. Thanks everyone!
Floor 7 Posted 2008-10-10 22:20 ·  中国 安徽 滁州 电信
初级用户
Credits 35
Posts 20
Joined 2008-10-02 11:10
17-year member
UID 127220
Gender Male
Status Offline
Floor 8 Posted 2009-10-21 09:55 ·  中国 江苏 南京 电信
初级用户
★★
Credits 62
Posts 62
Joined 2007-07-14 14:39
19-year member
UID 93962
Gender Male
Status Offline
It should be to add one more % character. Special symbols need to be defined in batch processing. For example, for the "|" character, if you want to output it, you need to add a "^" character in front.
Floor 9 Posted 2009-10-21 17:43 ·  中国 广东 深圳 电信
初级用户
Credits 40
Posts 23
Joined 2009-10-15 21:49
16-year member
UID 153140
Gender Male
Status Offline
Originally posted by radem at 2008-9-26 01:12:
%%%%i

nod
Forum Jump: