Splitting files with 7zip without compression
I have to copy a large (12GB) file to an external USB Drive that’s formatted in FAT32, which is limited to a maximum of 4GB per file.
I can split the files with the split command, but the owner of the disk has Windows, so I decided to generate a multipart 7zipped file from command line. As the original file is already compressed, I use no compression switch:
$ 7z a <filename> -mx0 -v4092m <file_to_be_compressed>
The switches stands for:
- -mx0: level of compression, where 0 means copy mode, i.e., no compression (usr/share/doc/p7zip-full/DOCS/MANUAL/switches/method.htm)
- -v4092m: create volume size of 4092 MB (/usr/share/doc/p7zip-full/DOCS/MANUAL/switches/volume.htm)
If you use -v4g to generate 4GB chunks, this 4GB will be grater than the FAT32 4GB, and it will be impossible to copy to the FAT32 USB drive (thanks to @Nicolas R. for pointing -v4092m, better than -v4000m posted originally).
Once completed, you’ll have several files deppending on the size of the file to compress, named filename.7z.001, filename.7z.002, …
I have one requirement to split a huge csv file in smaller chunks. I am using below command but after split I can see the the start of 1 split file and the end of last file has some junk data added to it.
example of junk is below:
7z¼¯’ cù¼Y b =àU´
command used:
“C:\Program Files\7-Zip\7z.exe” a “C:\Divya\TEST\test.csv” -m0=copy -sccWIN -v1M “C:\Divya\BigFile\BIGFILE.csv”
LikeLike
The “junk” is because the file is a 7zip file. Instead of test.csv, you have to use test.7z (7zip extension) and the result of the command is a 7zipped file (without compression, but 7zipped). Use this command:
“C:\Program Files\7-Zip\7z.exe” a “C:\Divya\TEST\test.7z” -m0=copy -sccWIN -v1M “C:\Divya\BigFile\BIGFILE.csv”
Then you can send the different spllitted parts (test,7z.001, test.7z.002, etc.) by mail, or whatever. The receiver must use 7zip again to uncompress the splitted parts.
LikeLike
You can optimize the parameter with -v4092m (4 x 1023 MB is ok for FAT32, 4 x 1024 is the actual limit)
LikeLike
Thanks Nicolas, I’ve updated the post with your suggestion.
LikeLike
Nice. This (splitting without compression) should have been implemented in gnome/cinnamon years ago.
LikeLike
Hi! Thank you very much for this tutorial. I was curious if you knew a way to split a text file by lines instead of max size. We have txt file with a bunch of records on each line. When I split it by size, it cut some of the lines in half, which break the record and give us false-positives. Any info would be greatly appreciated!!
LikeLike
Hi Jason, check out this excellent post In Unix, how can I split large files into a number of smaller files?
LikeLike
please help me regarding,how to merge 7z splitted files using c# code
LikeLike
I’m sorry, but I can’t help you as I’m not familiar with C#
LikeLike
Thanks for your post. How do you reassemble the split files into a single file?
LikeLike
Hi @Bostonian, You don’t need to reassemble the files, as you get a multipart compressed file. You just have to open the first compressed file (<filename>.7z.001) with your file explorer (nautilus) and extract to the desired folder. Or extract the file via the command line using:
7z x <filename>.7z.001
LikeLiked by 1 person
Nice tip. Though I think it should be `7z a -mx0 -v4000m `.
LikeLike
You’re right!, I’ve updated the mistake. Thanks!
LikeLike