是什么%〜D0在Windows批处理文件是什么意思? [英] What does %~d0 mean in a Windows batch file?
问题描述
我期待在一个批处理文件,它定义了以下变量:
I'm looking at a batch file which defines the following variables:
set _SCRIPT_DRIVE=%~d0 set
set _SCRIPT_PATH=%~p0
做什么%〜D0或%〜P0实际上意味着什么呢?有没有喜欢的事情当前目录,驱动器,参数,脚本一组著名的价值观?是否有任何其他类似的快捷方式,我可以使用?
What do %~d0 or %~p0 actually mean? Is there a set of well-known values for things like current directory, drive, parameters to a script? Are there any other similar shortcuts I could use?
推荐答案
神奇的变量%
的 N 的包含用于调用该文件的参数:%0
是路径蝙蝠文件本身,%1
是第一个参数后,%2
是第二等。
The magic variables %
n contains the arguments used to invoke the file: %0
is the path to the bat-file itself, %1
is the first argument after, %2
is the second and so on.
由于参数往往文件路径,有一些额外的语法以提取路径的部分。 〜d个
是驱动器,〜P
是路径(无硬盘),〜N
是文件名。它们可以组合使〜DP
是驱动器+路径。
Since the arguments are often file paths, there is some additional syntax to extract parts of the path. ~d
is drive, ~p
is the path (without drive), ~n
is the file name. They can be combined so ~dp
is drive+path.
%〜DP0
因此,pretty有用的蝙蝠:它是在其中执行bat文件驻留
%~dp0
is therefore pretty useful in a bat: it is the folder in which the executing bat file resides.
您还可以得到其它类型的有关文件的元信息:〜牛逼
为时间戳,〜Z
的大小。
You can also get other kinds of meta info about the file: ~t
is the timestamp, ~z
is the size.
这里为所有命令行参考看看命令。代字号幻codeS是根据描述。
这篇关于是什么%〜D0在Windows批处理文件是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!