2016-04-18 86 views
1

我需要爲嵌套文件夾創建cab文件。Makecab空格

所以我sreate DDF文件看起來:

.OPTION EXPLICIT ; Will Generate errors for mistakes 
.Set Compress=on 
.Set Cabinet=on 

; Destination Folder 
.Set DiskDirectory1= my Directory 


; File name for the new cab file 
.Set CabinetNameTemplate=Sample.cab 

//---------------- 

現在在bat文件我插入的所有文件到DDF文件列表:

cd %folderDir% 

@echo off 
call :treeProcess 
goto :eos 


:treeProcess 

for /f "delims=" %%a IN ('dir /a:-d/b 2^>nul ') do echo %%~fa >>%pathDdfFile% 

for /D %%d in (*) do (
    echo .Set DestinationDir=%%d >>%pathDdfFile% 
cd %%d 
    call :treeProcess 
    cd .. 
) 
goto :eof 

:eos 

cd \ 

//--------------- 

當我運行:

makecab /F %pathDdfFile% /L C:\temp 

它還給我:

意外的文字:一個文件

在有名稱化妝問題有空間的全部文件/ 我應該怎麼辦?

+0

所以要駕駛室整個目錄? – npocmaka

+1

你可以試試'for/f「delims =」%% a IN('dir/a:-d/b 2 ^> nul')do echo %%〜fa >>「%pathDdfFile%」'(雙引號圍繞文件路徑) – npocmaka

+0

謝謝,但我創建的ddf文件看起來很好,問題出現在名稱中具有空格的文件中: .Set DestinationDir = Mydir c:\ tmp 1 2 3.dll then我收到 錯誤:意外的文本:3.dll – liraz

回答