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,018 Replies 59
Floor 16 Posted 2005-08-08 11:31 ·  中国 上海 徐汇区 电信
银牌会员
★★★
永遠的DOS~~~
Credits 1,200
Posts 466
Joined 2005-02-01 00:00
21-year member
UID 35867
Gender Male
From 上海
Status Offline
It would be great if the pure DOS command interpreter could be as powerful as the CMD in 2K/XP someday
32位才是DOS未来的希望
个人网志:http://sololand.moe
Floor 17 Posted 2005-11-02 23:13 ·  中国 广东 深圳 南山区 电信
新手上路
Credits 4
Posts 2
Joined 2005-10-04 00:55
20-year member
UID 43102
Gender Male
Status Offline
Been looking for this for a long time~` bump bump bump!!
Floor 18 Posted 2007-05-17 00:52 ·  中国 广东 珠海 电信
新手上路
Credits 4
Posts 3
Joined 2007-05-16 23:36
19-year member
UID 88762
Gender Male
Status Offline
I'm completely convinced... DOS commands are really powerful...
Floor 19 Posted 2007-05-17 15:25 ·  中国 广东 深圳 联通
新手上路
Credits 16
Posts 7
Joined 2006-09-29 02:27
19-year member
UID 63994
Gender Male
From 河南省南阳市
Status Offline
When I use the AT command to run a batch file on schedule, if the batch file contains FOR, it just never works.


for /f %%a in (to.txt) do del %%a /q

The to.txt file is in the current folder.

Every time it runs, it says it can't find the to.txt file. If I directly click the batch file to run it, there's no problem.

I don't know why... when called by at it just won't run successfully.....

Asking the experts, where is the problem?
Floor 20 Posted 2007-05-23 22:36 ·  中国 山东 联通
新手上路
Credits 10
Posts 5
Joined 2007-05-23 21:15
19-year member
UID 89105
Gender Male
From 山东淄博
Status Offline
c:\md yubin Such a simple batch file content made me unable to hold back and want to find someone to pour out my heartfelt joy. From c:\md yubin to IF for, how many detours I took, how much effort I went through, but in the end I was still tripped up by IF for. Asking some big brother or big sister who knows IF for to solve these two puzzles for me.
I don't want to ask people for help either, but I can't help it, who told me I'm so fond of dos. QQ 648620644
I've studied it for a long time and really just can't figure it out~~
Floor 21 Posted 2007-05-23 23:17 ·  中国 山东 泰安 联通
新手上路
Credits 10
Posts 4
Joined 2007-05-23 22:44
19-year member
UID 89109
Gender Male
Status Offline
Let me try replying to a post
Floor 22 Posted 2007-05-24 22:27 ·  中国 江西 九江 电信
新手上路
Credits 15
Posts 8
Joined 2007-05-16 10:31
19-year member
UID 88678
Gender Male
Status Offline
Thanks for the OP's support
Floor 23 Posted 2007-05-24 23:19 ·  中国 新疆 克拉玛依 电信
新手上路
Credits 2
Posts 1
Joined 2007-05-23 12:10
19-year member
UID 89051
Gender Male
Status Offline
Thanks
Floor 24 Posted 2007-05-25 10:44 ·  中国 广东 广州 南沙区 电信
新手上路
Credits 18
Posts 9
Joined 2007-05-24 22:51
19-year member
UID 89215
Gender Male
Status Offline
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?
Floor 25 Posted 2007-06-11 18:16 ·  中国 广东 阳江 电信
新手上路
Credits 3
Posts 2
Joined 2007-06-06 23:19
19-year member
UID 90510
Gender Male
Status Offline
Thanks a lot for sharing! I'm learning this now!
Floor 26 Posted 2007-06-19 23:00 ·  中国 广东 深圳 电信
新手上路
Credits 6
Posts 3
Joined 2007-03-16 03:01
19-year member
UID 81894
Gender Male
Status Offline
:P Sooner or later I'll learn this command
Floor 27 Posted 2007-06-19 23:11 ·  中国 上海 电信
中级用户
★★
Credits 231
Posts 112
Joined 2007-06-19 20:44
19-year member
UID 91827
Gender Male
Status Offline
"for" is really too useful now. Unlike in the past, when I could only use goto for everything. Once a bat file went past 100 lines, I had no idea where goto was jumping anymore.
Floor 28 Posted 2007-06-20 00:27 ·  中国 广东 湛江 电信
新手上路
Credits 2
Posts 1
Joined 2007-06-19 21:28
19-year member
UID 91835
Gender Male
Status Offline
Learned something. Thanks.
Floor 29 Posted 2007-06-20 18:51 ·  中国 广东 深圳 联通
初级用户
高級總監
Credits 65
Posts 27
Joined 2007-06-20 16:50
19-year member
UID 91895
Gender Male
From china
Status Offline
Bump, I don't use for very brilliantly...
走過路過,千萬別錯過。
Floor 30 Posted 2007-06-22 15:16 ·  中国 福建 厦门 电信
初级用户
Credits 66
Posts 32
Joined 2007-01-15 12:56
19-year member
UID 76587
Gender Male
Status Offline
I've finally seen the true charm of the FOR command.
If only it could all be a bit more detailed. Then I'd have no problem learning DOS
Forum Jump: