How to split a file using built-in Windows functionalities

This post explains how to split a file using built-in Windows 11 functionalities.

You can always use 7-zip or a similar tool, but they’re not available on all systems.

Step-by-step instructions

  1. Compress the file
  2. Split the file
  3. Merge the file

1. Compress the file

Compress the file from the GUI (right click > compress file).

Alternatively, you can do it using the Power Shell:

Compress-Archive -Path "C:\Path\To\Folder\*" -DestinationPath "C:\Output\myarchive.zip"

2. Split the file

Copy this code into a .ps1 file, or type this in a PowerShell terminal

$source = "C:\Output\myarchive.zip"
$destDir = "C:\Output"
$partSize = 20MB
$buffer = New-Object byte[] $partSize
$in = [System.IO.File]::OpenRead($source)
$index = 1

while ($bytesRead = $in.Read($buffer, 0, $buffer.Length)) {
    $partName = Join-Path $destDir ("myarchive.part{0:D3}.zip" -f $index)
    $out = [System.IO.File]::Create($partName)
    $out.Write($buffer, 0, $bytesRead)
    $out.Close()
    $index++
}
$in.Close()

If you created a .ps1 file, you can run it by right-clicking on it and selecting “Run”.

If you aren’t allowed to run PS scripts in the system, you can try to write each row directly into the PowerShell.

3. Merge the files

Type this in the Power Shell terminal:

Get-ChildItem "C:\Output\myarchive.part*.zip" | Sort-Object Name | Get-Content -Encoding Byte -ReadCount 0 | Set-Content -Encoding Byte "C:\Output\myarchive_joined.zip"

Leave a Reply

Your email address will not be published. Required fields are marked *