|
flysp
中级用户
  
积分 207
发帖 41
注册 2004-10-24
状态 离线
|
『楼 主』:
[已结]空格目录下的FOR命令显得困惑
使用 LLM 解释/回答一下
假如
C:\Program Files\Internet Explorer\
存在1.txt 2.txt
执行
cd \
c:
dir /s /b 1.txt >ml.txt
dir /s /b 2.txt >>ml.txt
for /f %%i in (ml.txt) do @echo %%i | del %%i
最后的结果不成功
在命令行下用
for /f %i in (c:\ml.txt) do @echo %i
显示:C:\Program
居然不显示全部的路径。不知所以了,Program Files,只显示空格前的,不显示全部路径。这样想删除文件也不成了。怎么才能避免这个空格呢?
试了这两个
for /f %i in (c:\ml.txt) do @echo " %i"
for /f %i in (c:\ml.txt) do @echo %~fi
都不成啊
:(不知所以。
Last edited by willsort on 2006-7-23 at 13:14 ]
Suppose
C:\Program Files\Internet Explorer\
exists 1.txt 2.txt
Execute
cd \
c:
dir /s /b 1.txt >ml.txt
dir /s /b 2.txt >>ml.txt
for /f %%i in (ml.txt) do @echo %%i | del %%i
The final result is not successful
Under the command line, use
for /f %i in (c:\ml.txt) do @echo %i
It shows: C:\Program
It doesn't show the entire path. I don't understand. For Program Files, it only shows the part before the space, not the entire path. So it's impossible to delete the file. How to avoid this space?
Tried these two
for /f %i in (c:\ml.txt) do @echo " %i"
for /f %i in (c:\ml.txt) do @echo %~fi
None of them work
:( I don't understand.
Last edited by willsort on 2006-7-23 at 13:14 ]
|
|
2006-7-13 19:26 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
呵呵,知道WHY吗?
那是因为你的for命令缺少一个DELIMS= 的参数
for /f “ delims=" %i in (c:\ml.txt) do @echo %i
你在试试,哈哈哈...........
Hehe, do you know WHY? That's because your for command is missing a DELIMS= parameter. for /f " delims=" %i in (c:\ml.txt) do @echo %i Try it again, haha...........
|
|
2006-7-14 09:36 |
|
|
flysp
中级用户
  
积分 207
发帖 41
注册 2004-10-24
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
thank bagpipe。可以了
不过还是要问问
delims 不是定位分隔符号的吗?我的前边不成功是不是FOR本身默认的是TOKEN里边的每一行一第一列啊。^_^看来我还是对这些参数有些不懂
"delims="在这里,是不是就是不分界,没有分隔符的意思
要学习中……
万分感谢
Last edited by flysp on 2006-7-14 at 12:26 ]
thank bagpipe. It's okay. But still need to ask. Isn't delims the symbol to locate the delimiter? Is my previous failure because FOR itself defaults to the first column of each line in TOKEN? ^_^ It seems I still don't understand these parameters very well. "delims=" here, does it mean no delimitation, no delimiter? Need to study... Thanks a lot.
Last edited by flysp on 2006-7-14 at 12:26 ]
|
|
2006-7-14 12:12 |
|
|
bagpipe
银牌会员
     DOS联盟捡破烂的
积分 1144
发帖 425
注册 2005-10-20 来自 北京
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
因为DELIMS=默认的是以空格和<TAB>为默认值的,所以当你一行中出现有空格的时候他只取第一个空格之前的内容,明白???
Because the default for DELIMS is spaces and <TAB>, so when there are spaces in a line, it only takes the content before the first space, got it???
|
|
2006-7-14 13:10 |
|
|
buddiyar
初级用户
 
积分 160
发帖 75
注册 2006-6-28
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
"FOR本身默认的是TOKEN里边的每一行一第一列"???
汗啊 最近一直在找关于for的用法 竟然不知还有这等要事
算是知道自己是多菜了
刻骨铭心啊 小的记下了:
对于有空格的文本行要使用delims=
"FOR itself defaults to the first column of each line in TOKEN"???
Sweat ah, I've been looking for the usage of for recently and actually didn't know there was such an important matter.
I can be considered to know how naive I am.
Unforgettable ah, the little one remembers:
For text lines with spaces, use delims=
|
|
2006-7-14 23:57 |
|
|
flysp
中级用户
  
积分 207
发帖 41
注册 2004-10-24
状态 离线
|
|
2006-7-15 15:12 |
|
|
IceCrack
中级用户
   DOS之友
积分 332
发帖 168
注册 2005-10-6 来自 天涯
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
for的命令值得我们去深入的了解啊
The command is worth us to have an in - depth understanding.
|
|
2006-7-22 20:13 |
|
|
ke
新手上路

积分 4
发帖 2
注册 2006-9-28
状态 离线
|
|
2006-10-2 19:20 |
|
|
jieok3375
中级用户
  
积分 282
发帖 130
注册 2006-9-20 来自 广东
状态 离线
|
|
2006-10-16 00:33 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
for /f “ delims=" %i in (c:\ml.txt) do @echo %i
for默认的分格符为空格, 而"delims="是取消了默认分隔符, 以使整行内容得到提取.
使用"tokens=*"也可以达到同样效果, 它是把零列以后所有的内容都赋给一个变量%%?
for /f " delims=" %i in (c:\ml.txt) do @echo %i
The default delimiter for for is space, and "delims=" cancels the default delimiter to extract the entire line content.
Using "tokens=*" can also achieve the same effect, which assigns all content after column zero to a variable %%?
|
|
2006-10-16 10:20 |
|