本文介绍了%〜1和%1的批次之间有区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In batch i sometimes see %~1 used for switches and also %1. What's the difference? They both seem to work for me.

示例:

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

您可能会发现此链接很有趣运行.bat文件的命令

You may find this link interesting Command to run a .bat file

这篇关于%〜1和%1的批次之间有区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 15:20