How to Store a Folder Containing Huge Files in an Uncompressed ZIP on Windows

How to Store a Folder Containing Huge Files in an Uncompressed ZIP on Windows

Hello!

When backing up or archiving a folder that contains multiple large files, we often pack them into a ZIP file.

However, recompressing files that are already compressed (videos, images, PDFs, and so on) can take a long time while yielding little benefit—or make the compression step painfully slow. When you are not trying to save space and simply want to bundle multiple files together, an "uncompressed ZIP" (store mode) is a good option.

This article explains how to store a folder in an uncompressed ZIP, especially when it contains huge files (several GB to tens of GB).

The Limits of Windows' Built-in Features

With Windows Explorer's standard ZIP feature, you can right-click a file and choose "Send to" → "Compressed (zipped) folder," but this has two problems:

  1. There is no option to select no compression (store mode)
  2. It always compresses, so processing large files takes a long time

PowerShell's Uncompressed ZIP Command and Its Limitations

PowerShell provides theCompress-Archivecmdlet, and its-CompressionLevel NoCompressionoption lets you create an uncompressed ZIP.

Compress-Archive -Path "C:\example_backup" -DestinationPath "C:\temp\example_backup.zip" -CompressionLevel NoCompression

However, this command has limitations:

  • The maximum file size is 2 GB (due to a limitation in the Microsoft .NET API)
  • In practice, errors frequently occur once the folder size reaches around 20 GB

Example Error Messages

Running it on a folder containing large files produces errors like the following:

Exception calling "Write" with "3" argument(s): "Stream was too long."
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:820 char:29
+ ...                     $destStream.Write($buffer, 0, $numberOfBytesRead)
+                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : IOException

If you try to write the output to a location with restricted permissions, you may also see this error:

New-Object : Exception calling ".ctor" with "2" argument(s): "Access to the path 'C:\example_backup.zip' is denied."
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:729 char:30
+ ... ileStream = New-Object -TypeName System.IO.FileStream -ArgumentList $ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

In short, PowerShell'sCompress-Archiveis handy for small to mid-sized files, but it is not suited to huge ones.

Honestly, you just want to zip things up without having to worry about the size of each individual file, right?

The Solution: 7-Zip

This is where the mightiest of ZIP tools, 7-Zip, comes in.
It is an open-source, high-performance compression and extraction tool—and a truly excellent one.

  • Supports saving with no compression (store mode)
  • Effectively no file size limit (it can handle files of 50 GB and beyond)
  • Can be operated from the command line
  • Supports a wide variety of archive formats

Installing 7-Zip with Chocolatey

Now let's install 7-Zip from the command line. I use Chocolatey, a package manager for Windows that works much like apt.
It makes installing 7-Zip from the command line easy.

1. Install Chocolatey (if you don't have it yet)

Open PowerShellas Administratorand run the following command:

Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

2. Install 7-Zip

Once Chocolatey is installed,
still in an elevated PowerShell session, install 7-Zip with the following command:

choco install 7zip -y

-yoption automatically answers "yes" to any confirmation prompts.

Creating an Uncompressed ZIP with 7-Zip

Now let's actually create an uncompressed ZIP with 7-Zip.

As an example, we will store theC:\example_backupfolder in an uncompressed ZIP.

Steps in PowerShell

  1. Open PowerShell (no administrator privileges needed)
  2. Paste the following command into PowerShell:
$7zipPath = "C:\Program Files\7-Zip\7z.exe"
& $7zipPath a -tzip -mx0 "C:\temp\example_backup.zip" "C:\example_backup\*"

What this command does

  • a: the command that adds files to an archive
  • -tzip: specifies the ZIP format
  • -mx0: specifies no compression (store mode)
  • The first path is the output ZIP file
  • The second path is all the files inside the folder to be archived
  1. Wait for the process to finish (it takes a while for large files)

Summary

To store a folder containing huge files in an uncompressed ZIP:

  1. Windows' built-in ZIP feature has no store-mode option, so it is a poor fit
  2. PowerShell'sCompress-Archiveruns into problems with files over 2 GB
  3. 7-Zip is the best solution (and easy to install with Chocolatey)
  4. 7-Zip's command line (with the-mx0option) can create uncompressed ZIPs

When it comes to zipping folders with huge files on Windows, 7-Zip has you covered.

Read more