Windows批处理中获取文件属性的一些方法
windows的batchfile可以有%0-%9参数,其中%0默认表示batchfile的全路径,%1-%9为用户的传入参数。
以下特殊标记可以用来获得文件的属性,如果对%0使用特殊标记,表示获得batachfile的相关属性,如果%1-%9中某个%*是个文件的路径,也可以使用如下特殊标记来获得%*表示文件的相关属性。
例如:D:\testfolder\test.bat
echooff echopathname: echo%1 echofullyqualifiedpathname: echo%~f1 echodirive: echo%~d1 echopath: echo%~p1 echoname: echo%~n1 echoextention: echo%~x1 echoshortname: echo%~s1 echoattribute: echo%~a1 echotime: echo%~t1 echosize: echo%~z1 echodirectory: echo%~dp1
调用时为D:\testfolder\test.bat"c:\test\newfolder\mytable.txt",输出如下:
D:\>echooff pathname: "c:\test\newfolder\mytable.txt" fullyqualifiedpathname: c:\test\NewFolder\mytable.txt dirive: c: path: \test\NewFolder\ name: mytable extention: .txt shortname: c:\test\NEWFOL~1\mytable.txt attribute: --a------ time: 2010-09-2715:01 size: directory: c:\test\NewFolder\
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短