Originally posted by shuaigeya at 2007-3-9 18:46:
if /i "%%~nxi"=="test.txt" 这一句我不明白是什么意思 结果我把这句去掉 也
可以用 呵呵
@echo off
for /f "delims=" %%i in ('dir /a-d /b /s 'd ...
for /?
另外,FOR 变量参照的替换已被增强。您现在可以使用下列
选项语法:
~I - 删除任何引号("),扩充 %I
%~fI - 将 %I 扩充到一个完全合格的路径名
%~dI - 仅将 %I 扩充到一个驱动器号
%~pI - 仅将 %I 扩充到一个路径
%~nI - 仅将 %I 扩充到一个文件名
%~xI - 仅将 %I 扩充到一个文件扩展名
%~sI - 扩充的路径只含有短名
%~aI - 将 %I 扩充到文件的文件属性
%~tI - 将 %I 扩充到文件的日期/时间
%~zI - 将 %I 扩充到文件的大小
%~$PATH:I - 查找列在路径环境变量的目录,并将 %I 扩充
到找到的第一个完全合格的名称。如果环境变量名
未被定义,或者没有找到文件,此组合键会扩充到
空字符串
可以组合修饰符来得到多重结果:
%~dpI - 仅将 %I 扩充到一个驱动器号和路径
%~nxI - 仅将 %I 扩充到一个文件名和扩展名
%~fsI - 仅将 %I 扩充到一个带有短名的完整路径名
%~dp$PATH:i - 查找列在路径环境变量的目录,并将 %I 扩充
到找到的第一个驱动器号和路径。
%~ftzaI - 将 %I 扩充到类似输出线路的 DIR
Originally posted by shuaigeya at 2007-3-9 18:46:
I don't understand the meaning of the sentence "if /i "%%~nxi"=="test.txt"". As a result, I removed this sentence and it still works. Hehe
@echo off
for /f "delims=" %%i in ('dir /a-d /b /s 'd ...
for /?
In addition, the replacement of FOR variable references has been enhanced. You can now use the following
option syntax:
~I - Remove any quotation marks ("), expand %I
%~fI - Expand %I to a fully qualified pathname
%~dI - Expand %I to only a drive letter
%~pI - Expand %I to only a path
%~nI - Expand %I to only a file name
%~xI - Expand %I to only a file extension
%~sI - The expanded path only contains the short name
%~aI - Expand %I to the file attributes of the file
%~tI - Expand %I to the date/time of the file
%~zI - Expand %I to the size of the file
%~$PATH:I - Find the directory listed in the path environment variable, and expand %I
to the first fully qualified name found. If the environment variable name
is not defined, or the file is not found, this combination key will expand to
empty string
Multiple results can be obtained by combining modifiers:
%~dpI - Expand %I to only a drive letter and path
%~nxI - Expand %I to only a file name and extension
%~fsI - Expand %I to a complete pathname with a short name only
%~dp$PATH:i - Find the directory listed in the path environment variable, and expand %I
to the first drive letter and path found.
%~ftzaI - Expand %I to a DIR-like output line