Home > ubuntu > Splitting files with 7zip without compression

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, …

Categories: ubuntu Tags: , , , ,
  1. Divya
    May 3, 2022 at 22:12

    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”

    Like

    • May 4, 2022 at 8:03

      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.

      Like

  2. Nicolas R
    May 24, 2017 at 14:18

    You can optimize the parameter with -v4092m (4 x 1023 MB is ok for FAT32, 4 x 1024 is the actual limit)

    Like

    • May 24, 2017 at 17:10

      Thanks Nicolas, I’ve updated the post with your suggestion.

      Like

  3. March 6, 2016 at 17:57

    Nice. This (splitting without compression) should have been implemented in gnome/cinnamon years ago.

    Like

  4. Jason
    July 6, 2015 at 22:52

    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!!

    Like

  5. varalakshmi
    June 27, 2014 at 7:25

    please help me regarding,how to merge 7z splitted files using c# code

    Like

    • June 28, 2014 at 16:58

      I’m sorry, but I can’t help you as I’m not familiar with C#

      Like

  6. Bostonian
    February 24, 2014 at 15:17

    Thanks for your post. How do you reassemble the split files into a single file?

    Like

    • February 25, 2014 at 9:25

      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

      Liked by 1 person

  7. August 28, 2013 at 4:31

    Nice tip. Though I think it should be `7z a -mx0 -v4000m `.

    Like

    • August 28, 2013 at 7:48

      You’re right!, I’ve updated the mistake. Thanks!

      Like

  1. No trackbacks yet.

Leave a reply to Nicolas R Cancel reply