上周,同事问我写批处理文件的一个问题,他要做的事情主要是深度拷贝文件,涉及到目录和文件名解析的问题。当时他抱怨了半天,说不好用。可我发现,
MS
其实已经做了这个工作了。例如:
%~
1
可以去掉参数两边的引号
%~
d1
可以得到盘符
等等
这是文档中关于参数的参数表
Modifier |
Description |
%~1
|
Expands %1 and removes any surrounding quotation marks (""). |
%~f1
|
Expands %1 to a fully qualified path name. |
%~d1
|
Expands %1 to a drive letter. |
%~p1
|
Expands %1 to a path. |
%~n1
|
Expands %1 to a file name. |
%~x1
|
Expands %1 to a file extension. |
%~s1
|
Expanded path contains short names only. |
%~a1
|
Expands %1 to file attributes. |
%~t1
|
Expands %1 to date and time of file. |
%~z1
|
Expands %1 to size of file. |
关于批处理文件详细的信息在微软网站:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true