34

How do I split and combine files in Windows?

I need to split large files into several small sized files and then combine them after I transfer them to another box.

I'm fine with doing this on the command line.

1
  • You can alternatively use GSplit. I found the utility incredibly helpful when I have to move large files to a hard disk that has a FAT32 file system. This program also creates an executable which can unite all the files after splitting them in the destination directory, which is very helpful. Jun 14, 2020 at 20:12

11 Answers 11

11

I tend to compress the required file to a ZIP file, setting a maximum file size so that it gets split.

This means that you will always have the program to get the initial file back available.

5
  • 3
    Addendum: 7-Zip can zip and split. Look for "Split to volumes, bytes", lower left corner when creating an archive in the GUI.
    – Nathaniel
    Dec 7, 2009 at 22:33
  • 1
    it can split even without archiving, just like the rest.
    – Molly7244
    Dec 8, 2009 at 0:37
  • I tried this one. Very nice! The size of the package is about 1MG, less than GSplit (1.5MG). I need this tool to transfer files to a remote through a very slow connection. Therefore, the size of app is very important. Dec 9, 2009 at 22:54
  • @David.Chu.ca Have a look at portable-apps various compressors, like portable-apps 7zip
    – user400344
    Feb 8, 2017 at 0:41
  • You can alternatively use GSplit. I found the utility incredibly helpful when I have to move large files to a hard disk that has a FAT32 file system. This program also creates an executable which can unite all the files after splitting them in the destination directory, which is very helpful. Jun 14, 2020 at 20:12
40

If you just want to combine files (which have already been split somewhere else) you can do this in a Windows command prompt natively:

copy /b example.ext.001+example.ext.002+example.ext.003+example.ext.004 example.ext
1
  • 1
    Note that Powershell also has a cmdlet Copy-Item with the alias copy. This cmdlet works differently. Apr 15, 2021 at 16:40
14

Use HJSplit. It is simply the best.

HJSplit is freeware and portable (300 KB), and it doesn't have to be installed.

There is an older free command-line version of Goetz's File Splitter. You may like this version if you plan on running batch scripts to split lots of files.

7-Zip is another free open source program that allows you split (with or without compression) and combine files, either via GUI (right click on the file → Split File... → choose size) or command line.

If you have Total Commander, it does that as well (Files → Split File...)

0
13

For splitting files to exact sizes, you could always use the Linux / Unix command-line tool split. The Windows version is here: http://unxutils.sourceforge.net/

Using the tool, you can split files to any size you would like, and you would use "cat" to recombine them.

For example:

split -b=10090000 bigfile.iso bigfile_part.

To split your files to exactly 10090000 bytes. Your output would look something like this:

bigfile_part.aa
bigfile_part.ab, etc.

To recombine, just do:

cat bigfile_part* > bigfile.iso
4
  • How do I split a stream. Trying to do this: some_long_running_data_process | split -l 10000 --name the_parts Nov 14, 2015 at 14:46
  • 1
    Please correct: the option is --b, not -b.
    – mgr326639
    Oct 25, 2016 at 12:06
  • 2
    Are you sure that cat guarantees that the output is ordered alphabetically? Because if it doesn't, the command will not fail with an error but just produce a different (and wrong) output.
    – mgr326639
    Oct 25, 2016 at 12:08
  • 2
    @mgr326639 Yes, globbing expansion is alphabetical. serverfault.com/a/122743
    – Massey101
    Sep 16, 2021 at 4:10
2

I've been using this:

type file1 file2 file3 > out
7
0

You can use WinRAR as a file splitter/joiner as well. To split a file into smaller files, select "Store" as the compression method and enter the desired value (bytes) into "Split to volumes" box. This way you can have split files named as filename.part1.rar, filename.part2.rar, etc.

0

You might want to use GSplit. It's a powerful and free file splitter that lets you split your large files into a set of smaller files called pieces.

0
0

In Cygwin (basic install), Bash shell:

dd if=archive.tar bs=512M | xz -e9fc | split -b4000m - /destination/path/archive_split.

Omit the xz pipe block if your archive is already compressed.

To splice your archive together:

cat archive_split.* > archive
0

You can use this https://sakaiws.com/tools/en/FileDivider

Files aren't uploaded to the server so it's safe to use.

0

In Powershell, you can install the file splitter module:

install-module filesplitter

Then you use the following command to split a file:

split-file "<absolute path to large file>" -PartSizeBytes 500MB

to split it into chunks of 500MB size.

To combine the junks to the original file, simply use the following CMD command: copy /b chunkfile1 + chunkfile2 + ... chunkfileX (see answer by @user190976)

-1

None of the other answers work for me. This one did,

Get-Content inputFile1.txt, inputFile2.txt | Set-Content joinedFile.txt

OR

Get-Content inputFile*.txt | Set-Content joinedFile.txt

More info in:

1
  • While you did the right thing by attributing the Stack Overflow answer, it appears to me you likely initially saw it on @harrymc's answer, since you also answered the same question yesterday. It would be nice to attribute both of them, IMHO, since I don't think you would have found the SO answer without @harrymc's. I'm going to make the edit to this answer to include both, but please do rollback my edit if I'm wrong about this. Thanks! Jan 5, 2023 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .