2015-11-11 48 views
-1

我錯過了什麼?批量命令,在命令中調用文件

@echo off 
rem - processfiles.bat - Processes all text files in the "source" folder: 
rem - Runs %executable% with each text file as parameter 
rem - Move the text file to the target folder after processing 

set SourceFolder=C:\Users\Chris\Desktop\Yield_Files 
set TargetFolder=C:\Users\Chris\Desktop\YieldCleanFiles 
set fin=default.set 


if not exist "%TargetFolder%" md "%TargetFolder%" 

echo Processing text files in %SourceFolder%: 

for %%f in (%SourceFolder%\*.txt) do call "C:\Program Files\Yield_Editor\yieldeditor.exe/csvin="(%SourceFolder%\*.txt)"/auto="y"/hide/fin=%fin%"%%f 

pause 

我必須有我每次我打電話的。exe時間上工作的文件名

時運行它說,它無法找到指定的文件,但我不知道哪一個是說話關於。

+1

從for循環中刪除**調用**。只需使用可執行文件的名稱 – cup

+0

刪除'@echo off',在命令提示符處啓動批處理文件,而不是雙擊,並觀察輸出結果。 – aschipfl

回答

0

for %%f in (%SourceFolder%\*.txt) do call "C:\Program Files\Yield_Editor\yieldeditor.exe/csvin="(%SourceFolder%\*.txt)"/auto="y"/hide/fin=%fin%"%%f 

必須最有可能的書面

for %%f in ("%SourceFolder%\*.txt") do "C:\Program Files\Yield_Editor\yieldeditor.exe" /csvin="%SourceFolder%\*.txt" /auto=y /hide /fin=%fin% "%%~f" 

for %%f in ("%SourceFolder%\*.txt") do "%ProgramFiles%\Yield_Editor\yieldeditor.exe" "/csvin=%SourceFolder%\*.txt" /auto=y /hide /fin=%fin% "%%~f" 

,這意味着你的可執行行必須以語法運行

"Path to Application\Application.exe" "/First Option" /Option2 /Option3 /Option4 "File Name As Fifth Parameter" 
應用程序與文件擴展名和路徑的

文件名必須加引號如果在命令提示符窗口中cmd /?運行時,至少1空間或有特殊的含義,在過去的幫助頁面上的命令提示符窗口輸出另一個字符顯示。這是應用程序的參數0。

第一個參數/選項是應用程序的參數1。如果參數字符串包含空格或其他特殊字符,則必須使用引號。不包含空格的選項不能被引用,但可以引用。

一些應用程序支持具有可變字符串的選項裏面引用。這種語法的一個例子是/csvin="%SourceFolder%\*.txt"

詳細內容請閱讀幫助/應用程序的文檔,使用它的命令行。大多數Windows控制檯應用程序都可以在命令提示符窗口中執行,只需將/?作爲將命令行幫助打印到控制檯的參數。

可以在這裏看到,爲什麼用空格參數字符串必須用引號括起來。空間是參數的分隔符。