中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-23 12:57
47,812 topics / 349,917 posts / today 0 new / 48,273 members
DOS批处理 & 脚本技术(批处理室) » [Sharing] Advanced Application Examples of the "FOR" Command
Printable Version  13,645 / 59
Floor46 17500 Posted 2007-12-04 20:29
新手上路 Posts 9 Credits 19
I've learned my lesson with for, it's too amazing
Floor47 popoweb Posted 2007-12-05 20:37
新手上路 Posts 10 Credits 21
Good post. Commands copied like this really ought to be explained in a special topic.
Floor48 fydncom Posted 2007-12-06 14:43
初级用户 Posts 12 Credits 26
Learning FOR, its features are really powerful
Floor49 hulongzhuo Posted 2007-12-28 11:28
中级用户 Posts 135 Credits 294
Very powerful, I finally learned FOR, so happy!!
Floor50 haiou327 Posted 2008-01-04 22:13
高级用户 Posts 348 Credits 713
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 ]
Floor51 riversail Posted 2008-01-09 23:16
初级用户 Posts 12 Credits 24
I really need to take a good look at this...
Thanks...
Floor52 aeihua Posted 2008-09-28 15:36
新手上路 Posts 6 Credits 12 From 江西省宜春市
Duplicate post? Can't be, right?
Floor53 mwm5 Posted 2009-10-18 04:55
初级用户 Posts 23 Credits 40
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...
Floor54 mwm5 Posted 2009-10-18 04:59
初级用户 Posts 23 Credits 40
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"
Floor55 nwgatx Posted 2009-12-14 15:06
新手上路 Posts 6 Credits 9
Many of the commands are wrong
Floor56 BeeButterflyDos Posted 2009-12-15 10:28
新手上路 Posts 16 Credits 17
Thanks a lot for sharing, bump~~~~~
Floor57 zghk Posted 2010-04-23 15:20
初级用户 Posts 7 Credits 117
A good thread for answering questions and clearing up confusion
Floor58 cjiabing Posted 2010-08-05 00:48
新手上路 Posts 18 Credits 19
Uh, how come I don't see anything new or unusual in it!?~ But I still support it!
Floor59 linc118 Posted 2010-10-28 11:16
新手上路 Posts 3 Credits 4
This came from for /?, right? I was wondering why it looked so familiar. It's really hard.
Floor60 yf6122010 Posted 2010-12-09 11:05
新手上路 Posts 18 Credits 18
Learning
Prev  1 2 3 4
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023