亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

%~d0在Windows批處理文件中的含義是什么?

%~d0在Windows批處理文件中的含義是什么?

慕姐8265434 2019-09-18 10:39:49
我正在查看定義以下變量的批處理文件:set _SCRIPT_DRIVE=%~d0set _SCRIPT_PATH=%~p0什么%~d0或%~p0實際意味著什么?對于諸如當前目錄,驅動器,腳本參數之類的東西,是否有一組眾所周知的值?我可以使用其他類似的快捷方式嗎?
查看完整描述

3 回答

?
PIPIONE

TA貢獻1829條經驗 獲得超9個贊

神奇變量%n包含用于調用文件的參數:%0是bat文件本身的路徑,%1是后面的第一個參數,%2是第二個參數,依此類推。


由于參數通常是文件路徑,因此有一些額外的語法來提取路徑的一部分。~d是驅動器,~p是路徑(沒有驅動器),~n是文件名。它們可以組合在一起,因此~dp驅動器+路徑。


%~dp0 因此在bat中非常有用:它是執行bat文件所在的文件夾。


您還可以獲得有關該文件的其他類型的元信息:~t是時間戳,~z是大小。


看看這里為所有命令行命令的參考。代字號幻代碼下所描述的。


查看完整回答
反對 回復 2019-09-18
?
幕布斯6054654

TA貢獻1876條經驗 獲得超7個贊

它們是增強的可變取代。它們修改批處理文件中使用的%N個變量。如果你在Windows中進行批量編程,那將非常有用。


%~I         - expands %I removing any surrounding quotes ("")

%~fI        - expands %I to a fully qualified path name

%~dI        - expands %I to a drive letter only

%~pI        - expands %I to a path only

%~nI        - expands %I to a file name only

%~xI        - expands %I to a file extension only

%~sI        - expanded path contains short names only

%~aI        - expands %I to file attributes of file

%~tI        - expands %I to date/time of file

%~zI        - expands %I to size of file

%~$PATH:I   - searches the directories listed in the PATH

               environment variable and expands %I 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

您可以通過運行找到上述內容FOR /?。


查看完整回答
反對 回復 2019-09-18
?
慕容森

TA貢獻1853條經驗 獲得超18個贊

是的,您可以使用下面給出的其他快捷方式。在你的命令中,~d0意味著第0個參數的驅動器號。


~ expands the given variable

d gets the drive letter only

0 is the argument you are referencing

由于第0個參數是腳本路徑,因此它會為您獲取路徑的驅動器號。您也可以使用以下快捷方式。


%~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    


%~dp1       - expands %1 to a drive letter and path only

%~nx1       - expands %1 to a file name and extension only

%~dp$PATH:1 - searches the directories listed in the PATH

               environment variable for %1 and expands to the

               drive letter and path of the first one found.

%~ftza1     - expands %1 to a DIR like output line

當你運行CALL /?時,也可以直接在命令提示符中找到它?;騀OR /?


查看完整回答
反對 回復 2019-09-18
  • 3 回答
  • 0 關注
  • 3245 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號