2016-04-18 32 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

回答