What's the best way to create a .cab file of multiple files quickly?

5

I would like to make a .cab file of multiple files. Any tutorial or guide I've come across is only useful for a few files.

Brendan Long

Posted 2013-10-12T18:38:25.147

Reputation: 55

Questions seeking product, service, or learning material recommendations are off-topic because they tend to become obsolete quickly. Instead, describe your situation and the specific problem you're trying to solve. Here are a few suggestions on how to properly ask this type of question.

– Doktoro Reichard – 2013-10-12T18:49:55.257

@DoktoroReichard This question is not asking for product or tutorial recommendations (the answer could be one but this is not off-topic). It is only saying all the tutorial and guides used before were not useful. The author is not asking for a recommendation but clearly for the way to do it in the title and of course this is not off topic. – laurent – 2013-10-12T19:51:31.380

@laurent not to make this into a debate, but the OP didn't state any tutorial or guide that he read in the question, and what's the best [tag:X-category] type of questions (read the last link) lead to product recommendations. I assume if someone would take the time to reformat this question it would be a valid one. – Doktoro Reichard – 2013-10-12T19:58:04.640

Answers

0

According to Wikipedia:

The CAB file format may employ the following compression algorithms:

  • DEFLATE – invented by Phil Katz, the author of the ZIP file format
  • Quantum compression – licensed from David Stafford, the author of the Quantum archiver
  • LZX – invented by Jonathan Forbes and Tomi Poutanen, given to Microsoft when Forbes joined the company

As such, any .zip compressor should open the file, even the one that's native with all recent Windows versions.

However, and as the article indicates, there are few archivers that create .cab files, due to their format. According to the following list these programs can write .cab files:

  • ZipGenius
  • AlZip
  • IZArc
  • PowerArchiver
  • TugZip
  • WinAce

Doktoro Reichard

Posted 2013-10-12T18:38:25.147

Reputation: 4 896

Tried until I got to IZArc. It made .cab files correctly. AIZip does not create .cabs. ZipGenius just doesn't seem to work (you tell it to create a .cab and then it does nothing). I am so surprised a Google search about creating .cab files didn't bring this up. Thanks a lot. – Brendan Long – 2013-10-12T19:08:09.140

6

You can use the Windows built-in command makecab but first you need to generate a file list.

dir C:\FolderName /s /b /a-d > c:\temp\files.txt

This will list all files in the C:\FolderName directory and save as a text file with full path name. Now we are going to use the files.txt file to create the cab file.

makecab /d CabinetName1=test.cab /D DiskDirectoryTemplate=C:\temp /f c:\temp\files.txt

The above command will generate a test.cab file in your C:\Temp folder using the file list generated earlier.

Additional helpful reference: Microsoft Cabinet Reference. and makecab.exe details.

anonymous coward

Posted 2013-10-12T18:38:25.147

Reputation: 750

It tells me A positional parameter cannot be found that accepts argument '/b'. with the first command. – Tvde1 – 2019-04-29T12:27:14.610

@tvde1, please check your syntax. The /b tells the output should only include bare path. Try this command "dir /?" For more details. – anonymous coward – 2019-04-29T13:53:13.560

@anonymouscoward It worked using the cmd terminal not PowerShell. a-d is wrong, the correct is a:-d. In makecab I had to pass a disk size using /d otherwise it would create floppy disk size cabinets – Clodoaldo – 2019-05-22T18:40:27.010

0

I needed to create a CAB file in a hurry for a project last week. What I really wanted to do was to replace a single file inside an existing CAB file, preserving the folder structure in the CAB. I soon learned that there was no simple 7Zip or WinZip way to do this in place, and that the success path was to generate a new CAB file with the modified files I wanted in it. This tool to create a CAB file from all files in a folder worked beautifully for me. It is a GUI front end to the MakeCab utility that creates It is described here: https://yieldreturnpost.wordpress.com/2016/06/22/free-tool-to-create-cab-file-from-folder/ The GitHub source is here: https://github.com/sapientcoder/CabMaker

First, I used the Expand command to extract the files from the existing CAB file to a folder structure.

expand -F:* \\MyServer\ServerMigration2020\ExportedConfigurationSourceFiles\MyOriginalCABFile.cab \\MyServer\CaptureSV\ServerMigration2020\Cabfiles\CabSourceFiles 

This Expand command extracted all the files inside my CAB file and placed them in the folder CabSourceFiles, preserving the folder structure.

Now, we are ready to run the CabMaker GUI to create our CAB file. Note that this is a "plain" CAB file of just files and folders, not one that has extra headers and such as part of a set of installer files.

I simply downloaded the CabMaker C# code and ran it in Visual Studio 2019. Up came the GUI. I entered my Source folder (the output folder in the Expand command), and my Target folder (where the resulting CAB file gets placed), and my desired CAB file name, and clicked the "Make CAB" button, and it ran. The resulting CAB file worked beautifully, and imported successfully into the app and resulted in a correctly set configuration.

CabMaker GUI screen shot

OK, so why did I need to make a CAB file? Well, we were migrating a vendor app from an old server to a new server, and using the app's "export" function to capture current state configuration files that we could "import" into the app on the new server. the alternative was to use the clunky GUI of the consumer app to manually navigate around and make a couple hundred changes to file and folder names that had changed. I decided it would be better to make the file and folder changes in the XML file within the CAB that held all the settings. It all worked out beautifully on server cutover day; sometimes we get lucky. Major kudos to GitHub contributor SapientCoder!

Developer63

Posted 2013-10-12T18:38:25.147

Reputation: 296