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-07 10:18
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Sharing] Advanced Application Examples of the "FOR" Command View 13,019 Replies 59
Floor 46 Posted 2007-12-04 20:29 ·  中国 广东 佛山 电信
新手上路
Credits 19
Posts 9
Joined 2007-11-22 01:28
18-year member
UID 103384
Gender Male
Status Offline
I've learned my lesson with for, it's too amazing
Floor 47 Posted 2007-12-05 20:37 ·  中国 内蒙古 呼和浩特 中移铁通
新手上路
Credits 21
Posts 10
Joined 2007-11-30 14:45
18-year member
UID 104246
Gender Male
Status Offline
Good post. Commands copied like this really ought to be explained in a special topic.
Floor 48 Posted 2007-12-06 14:43 ·  中国 河北 石家庄 联通
初级用户
Credits 26
Posts 12
Joined 2007-12-05 12:34
18-year member
UID 104730
Gender Male
Status Offline
Learning FOR, its features are really powerful
Floor 49 Posted 2007-12-28 11:28 ·  中国 广东 东莞 电信
中级用户
★★
Credits 294
Posts 135
Joined 2007-03-09 14:47
19-year member
UID 81212
Gender Male
Status Offline
Very powerful, I finally learned FOR, so happy!!
Floor 50 Posted 2008-01-04 22:13 ·  中国 广东 汕头 潮阳区 电信
高级用户
★★★
DOS时空
Credits 713
Posts 348
Joined 2007-02-10 13:59
19-year member
UID 79169
Gender Male
Status Offline
RE wandyac
for %a in (c: d: e: f do @dir %a\ | find "bytes free"
This line?
for %%a in (c: d: e: f) do (
@dir %%a\ | find "bytes free"
)
Like this?
It still doesn't execute successfully this way either

[ Last edited by haiou327 on 2008-1-4 at 10:17 PM ]
Floor 51 Posted 2008-01-09 23:16 ·  中国 湖南 长沙 电信
初级用户
Credits 24
Posts 12
Joined 2007-12-15 18:50
18-year member
UID 105758
Gender Male
Status Offline
I really need to take a good look at this...
Thanks...
Floor 52 Posted 2008-09-28 15:36 ·  中国 广东 深圳 电信
新手上路
Credits 12
Posts 6
Joined 2008-09-28 11:38
17-year member
UID 126873
Gender Male
From 江西省宜春市
Status Offline
Duplicate post? Can't be, right?
勤劳致富.多学多用.
Floor 53 Posted 2009-10-18 04:55 ·  中国 广东 深圳 电信
初级用户
Credits 40
Posts 23
Joined 2009-10-15 21:49
16-year member
UID 153140
Gender Male
Status Offline
Originally posted by rechard at 2007-5-25 10:44:
I just tried:
for %a in (*.txt) do type %a

But if the filename contains spaces, for example:
001.txt
复件 001.txt

it can only display 001.txt, but can't display the contents of the file "复件 001.txt". How should it be modified?


for %a in (*.txt) do type "%a"
Just add double quotes around the %a at the end...
Otherwise the type command thinks they're multiple files separated by spaces...
Floor 54 Posted 2009-10-18 04:59 ·  中国 广东 深圳 电信
初级用户
Credits 40
Posts 23
Joined 2009-10-15 21:49
16-year member
UID 153140
Gender Male
Status Offline
Originally posted by haiou327 at 2008-1-4 22:13:
RE wandyac
for %a in (c: d: e: f do @dir %a\ | find "bytes free"
This line?
for %%a in (c: d: e: f) do (
@dir %%a\ | fin ...


Only in a batch file do you use %%a; for ordinary commands use %a
for %a in (c: d: e: f:) do @dir %a\ | find "bytes free"
or inside a batch file

for %%a in (c: d: e: f:) do @dir %%a\ | find "bytes free"
Floor 55 Posted 2009-12-14 15:06 ·  中国 湖北 武汉 电信
新手上路
Credits 9
Posts 6
Joined 2008-09-29 16:42
17-year member
UID 127009
Gender Male
Status Offline
Many of the commands are wrong
Floor 56 Posted 2009-12-15 10:28 ·  中国 福建 厦门 教育网
新手上路
Credits 17
Posts 16
Joined 2009-10-16 19:14
16-year member
UID 153178
Gender Male
Status Offline
Thanks a lot for sharing, bump~~~~~
Floor 57 Posted 2010-04-23 15:20 ·  中国 云南 楚雄彝族自治州 电信
初级用户
Credits 117
Posts 7
Joined 2004-10-29 00:00
21-year member
UID 33078
Gender Male
Status Offline
A good thread for answering questions and clearing up confusion
Floor 58 Posted 2010-08-05 00:48 ·  中国 广西 南宁 电信
新手上路
Credits 19
Posts 18
Joined 2009-01-19 00:11
17-year member
UID 136996
Gender Male
Status Offline
Uh, how come I don't see anything new or unusual in it!?~ But I still support it!
Floor 59 Posted 2010-10-28 11:16 ·  中国 江苏 苏州 电信
新手上路
Credits 4
Posts 3
Joined 2010-10-27 22:11
15-year member
UID 176633
Gender Male
Status Offline
This came from for /?, right? I was wondering why it looked so familiar. It's really hard.
Floor 60 Posted 2010-12-09 11:05 ·  中国 广东 深圳 诺瓦科技发展有限公司
新手上路
Credits 18
Posts 18
Joined 2010-12-06 16:28
15-year member
UID 178780
Gender Male
Status Offline
Learning
Forum Jump: