windows的batchfile可以有%0-%9参数,其中%0默认表示batchfile的全路径,%1-%9为用户的传入参数。

以下特殊标记可以用来获得文件的属性,如果对%0使用特殊标记,表示获得batachfile的相关属性,如果%1-%9中某个%*是个文件的路径,也可以使用如下特殊标记来获得%*表示文件的相关属性。

例如:D:\testfolder\test.bat

复制代码 代码如下:

echo off

echo path name:

echo %1

echo fully qualified path name:

echo %~f1

echo dirive:

echo %~d1

echo path:

echo %~p1

echo name:

echo %~n1

echo extention:

echo %~x1

echo short name:

echo %~s1

echo attribute:

echo %~a1

echo time:

echo %~t1

echo size:

echo %~z1

echo directory:

echo %~dp1

调用时为D:\testfolder\test.bat “c:\test\new folder\mytable.txt”,输出如下:

复制代码 代码如下:

D:\>echo off

path name:

“c:\test\new folder\mytable.txt”

fully qualified path name:

c:\test\New Folder\mytable.txt

dirive:

c:

path:

\test\New Folder\

name:

mytable

extention:

.txt

short name:

c:\test\NEWFOL~1\mytable.txt

attribute:

–a——

time:

2010-09-27 15:01

size:

directory:

c:\test\New Folder\

您可能感兴趣的文章:

声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。