![]() |
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-08-13 23:01 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » [Help] Question for all the veterans! About the for command? |
| Printable Version 638 / 6 |
| Floor1 hzy | Posted 2003-07-21 00:00 |
| 高级用户 Posts 135 Credits 578 | |
|
Why is it that when I run:
for /r c:\exe %a in (*.exe) do echo %~na it always says: Syntax error ?? |
|
| Floor2 Lydong | Posted 2003-07-22 00:00 |
| 元老会员 Posts 407 Credits 1,468 From 广州 | |
|
for is an important internal command in DOS. Its usage format is like this:
FOR %C IN (item1......) DO command Here is an example: If we want to view the contents of three text files A, B, and C, we would generally enter it like this: C:\>TYPE A A C:\>TYPE B B C:\>TYPE C C Another method is: C:\>for %c in (a,b,c) do echo %c (The result is as follows) C:\>echo a a C:\>echo b b C:\>echo c c If you want to display files of the .txt, .doc, and .WPS types in the current directory respectively, you can enter it like this: for %i in (×.txt,*.doc,*.wps) do dir %i In a batch file, the loop variable needs 2 percent signs (%%C), while if executed directly on the command line, only one % is needed. |
|
| Floor3 hzy | Posted 2003-07-22 00:00 |
| 高级用户 Posts 135 Credits 578 | |
|
Thanks
|
|
| Floor4 leslie | Posted 2003-07-27 00:00 |
| 初级用户 Posts 16 Credits 178 | |
|
Really learned something
|
|
| Floor5 五笔之神 | Posted 2003-07-27 00:00 |
| 初级用户 Posts 10 Credits 148 | |
|
Sigh, do you have to learn programming before you can learn batch files?!
|
|
| Floor6 6618 | Posted 2003-07-27 00:00 |
| 中级用户 Posts 54 Credits 356 | |
|
Support, it would be even better if it were more detailed!
|
|
| Floor7 duxuelj520 | Posted 2004-08-03 00:00 |
| 初级用户 Posts 55 Credits 217 | |
|
Right
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |