1

I need to create cab file for nested folder .

so I sreate ddf file that looks :

.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 

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

now in the bat file I insert the list of all files to the ddf file :

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 \

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

when I run :

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

its return me :

unexpected text : one file

all files that have space in there name make problem/ what should I do ?

liraz
  • 21
  • 4
  • so you want to cab a whole directory? – npocmaka Apr 18 '16 at 08:51
  • 1
    you can try with `for /f "delims=" %%a IN ('dir /a:-d/b 2^>nul ') do echo %%~fa >>"%pathDdfFile%"` (double quotes around the file path) – npocmaka Apr 18 '16 at 08:53
  • Thanks , but the ddf file that I create looks fine , the problem is in files that have space in the name like : .Set DestinationDir=Mydir c:\tmp 1 2 3.dll then I get ERROR : Unexpected text : 3.dll – liraz Apr 18 '16 at 09:25
  • Oh ok I understand !! thank you very much for /f "delims=" %%a IN ('dir /a:-d/b 2^>nul ') do echo "%%~fa" >>%pathDdfFile% "c\temp 1 2 3.dll" the cab is create but when I try to open it I get : can not open file as archive – liraz Apr 18 '16 at 10:00

1 Answers1

-1

You can check this script that will cab a directory recursively.Example:

call cabdir.bat "C:\someDir" some.cab

You can also check this question

Community
  • 1
  • 1
npocmaka
  • 55,367
  • 18
  • 148
  • 187