1

我有這樣的事情使用文件名作爲批處理文件中的參數

FOR %%A IN ("Drawings\*.txt") DO draw.exe /f %%A /d ONLY_FILENAME 

但我需要自動把文件名各TXT文件到字符串爲「/ d ...」參數。

例子: 我的文件 「第一FILE.TXT」 在我的圖紙目錄。自動生成的字符串必須是這樣的一個

FOR %%A IN ("Drawings\*.txt") DO 

draw.exe /f "Drawings\The First File.txt" /d "The First File" 

如何做到這一點?

回答

1
FOR %%A IN ("Drawings\*.txt") DO draw.exe /f "%%A" /d "%%~nA" 

下面是尋求幫助的摘錄:

In addition, substitution of FOR variable references has been enhanced 
You can now use the following optional syntax: 

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

非常感謝您!有用!!! – 2014-12-06 16:09:12

相關問題