2017-11-22 4 views
0

バッチiでは、スイッチとして%~1が使用され、%1が表示されることがあります。違いは何ですか?彼らはどちらも私のために働くようです。バッチでの%〜1と%1の違いは?

例:

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

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

はinterchangibly動作するようです。 ( ")

答えて

1

説明は両方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

+0

ありがとう!面白いこのリンクを見つけることができます。 – ditheredtransparency

関連する問題