2013-10-16 2 views
14

디렉토리에 파일 묶음이 있습니다. 내가 makecab 다음 시도했지만 폴더에있는 모든 파일을 cab 파일에 포함되지 않습니다.makecab - 폴더의 모든 파일에서 cab 파일 만들기

makecab /d "C:\Users\crtorres\Documents\- SouthPacific Project 2014\- Projects\Sales Doc Center\New Region" test.cab 

다음은 작동하지만 cab 파일에는 매니페스트 파일 만 있습니다. makecab manifest.xml test.cab

답변

12
스위치가 파일을 사용할 수 없습니다

/D :

@echo off 
dir /s /b /a-d >files.txt 
makecab /d "CabinetName1=test.cab" /f files.txt 
del /q /f files.txt 

More info

here 전체 디렉토리 구조를 보존하는 스크립트를 찾을 수 있습니다 EDIT

+0

"files.txt"의 경우 파일 경로 및 이름에서가 아니라 "files.txt"에 추가됩니다. 그러면 files.txt도 test.cab에있게됩니다. – Hinek

22

필자는 마침내 실제로 이것을 제대로 수행 할 수있는 스크립트를 만들었습니다 (powershell 사용)

WSPBuilder를 자주 사용하지 않으므로 새로운 소프트웨어/추가 파일을 다운로드하는 것이 불편합니다. 이것은 OOTB에서 작동합니다.

function compress-directory([string]$dir, [string]$output) 
{ 
    $ddf = ".OPTION EXPLICIT 
.Set CabinetNameTemplate=$output 
.Set DiskDirectory1=. 
.Set CompressionType=MSZIP 
.Set Cabinet=on 
.Set Compress=on 
.Set CabinetFileCountThreshold=0 
.Set FolderFileCountThreshold=0 
.Set FolderSizeThreshold=0 
.Set MaxCabinetSize=0 
.Set MaxDiskFileCount=0 
.Set MaxDiskSize=0 
" 
    $dirfullname = (get-item $dir).fullname 
    $ddfpath = ($env:TEMP+"\temp.ddf") 
    $ddf += (ls -recurse $dir | ? {!$_.psiscontainer}|select -expand fullname|%{'"'+$_+'" "'+$_.SubString($dirfullname.length+1)+'"'}) -join "`r`n" 
    $ddf 
    $ddf | Out-File -encoding UTF8 $ddfpath 
    makecab /F $ddfpath 
    rm $ddfpath 
    rm setup.inf 
    rm setup.rpt 
} 

내가 잘못하고 있고/있거나 더 나을 수도 있는지 알려 주시기 바랍니다. 참조

:

http://www.pseale.com/blog/StrongOpinionSayNoToMAKECABEXE.aspx

+7

이것은 예쁘지만 사용법 : Open PowerShell; 이 함수를 PowerShell에 붙여 넣습니다. 누르기; compress-directory. \ some-dir-to-compress. \ filename.cab – turiyag

+1

이 오래된 게시물에서 누가 실행되는지 알고 있어야하는 몇 가지 사용법 문제. 목적지는 문자 적 ​​경로를 취하지 않습니다. 일시적인 해결책으로 위치를 밀거나 팝 할 수 있습니다. 명령은 "compress-directory c : \ temp. \ temp.cab"와 유사합니다.
또한 2GB - 512 바이트를 초과 할 경우 cab 파일에 문제가 있습니다. 추가 옵션으로 압축 유형 LZX를 대안으로 설정할 수 있습니다. – Lorek

관련 문제