gpt4 book ai didi

batch-file - 批量 %~1 和 %1 之间的区别?

转载 作者:行者123 更新时间:2023-12-04 15:00:15 25 4
gpt4 key购买 nike

在批处理中,我有时会看到 %~1用于开关和 %1 .有什么不同?他们似乎都为我工作。

例子:

if "%~1"=="" echo No variable specified.


if "%1"=="" echo No variable specified.

似乎可以互换工作。

最佳答案

解释在For /?call /?扩展 %1 删除任何周围的引号 (")。

    %~1         - expands %1 removing any surrounding quotes (")
%~f1 - expands %1 to a fully qualified path name
%~d1 - expands %1 to a drive letter only
%~p1 - expands %1 to a path only
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only
%~s1 - expanded path contains short names only
%~a1 - expands %1 to file attributes
%~t1 - expands %1 to date/time of file
%~z1 - expands %1 to size of file
%~$PATH:1 - searches the directories listed in the PATH
environment variable and expands %1 to the fully
qualified name of the first one found. If the
environment variable name is not defined or the
file is not found by the search, then this
modifier expands to the empty string

您可能会发现此链接很有趣 Command to run a .bat file

关于batch-file - 批量 %~1 和 %1 之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47426129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com