splitting or merging parts of .zip or .tar.gz files
splitting or merging parts of .zip or .tar.gz files
Author
Discussion

puggit

Original Poster:

49,821 posts

278 months

Wednesday 24th May 2006
quotequote all
We have software which runs environmental reports on customer servers and then splits the resulting .zip file in to 1.9MB parts for easy emailing.

Now I understand how to merge the parts together - using "type newfile >> targetfile" - but when I've finished (10 files in all) I can't seem to open the result - usually winzip tries to make me add the file I'm opening to another .zip file

Do you think something went wrong between customer creating the files and me merging them? Invalid archive sometimes pops up too!

zumbruk

7,848 posts

290 months

Wednesday 24th May 2006
quotequote all
You sure he didn't split the file *then* zip them?

Did you download these off the web? Many browsers remove the file extensions (.zip, .gz, etc) without actually uncompressing the files, so Windows gets confused as to what they are. (The Linux "file" command will tell you what they are.)

puggit

Original Poster:

49,821 posts

278 months

Wednesday 24th May 2006
quotequote all
zumbruk said:
You sure he didn't split the file *then* zip them?

Did you download these off the web? Many browsers remove the file extensions (.zip, .gz, etc) without actually uncompressing the files, so Windows gets confused as to what they are. (The Linux "file" command will tell you what they are.)

It's our software which splits them... Gives them tags like file_aa_ac.zip, file_ab_ac.zip and file_ac_ac.zip

FourWheelDrift

92,350 posts

314 months

Wednesday 24th May 2006
quotequote all
Not sure how to help on the zip front, but for splitting files into smaller compressed forms I would always recommend WinRAR, you can specify the size of each part and it can create an automatic (.exe style) rar file, all you have to do is click it and it merges all the seperate RAR files back into their original form.

zumbruk

7,848 posts

290 months

Wednesday 24th May 2006
quotequote all
Are you sure you're catenating them in the correct order? You can't simply catenate .gz files in any old order, they're Huffman encoded.

puggit

Original Poster:

49,821 posts

278 months

Wednesday 24th May 2006
quotequote all
zumbruk said:
Are you sure you're catenating them in the correct order? You can't simply catenate .gz files in any old order, they're Huffman encoded.
Excuse me?

Sorry, I'm a windows bod - this unix/linux stuff scares me!

malman

2,258 posts

289 months

Thursday 25th May 2006
quotequote all
If the software that produces the file creates a big zip then splits it into 1.9M chunks then you should be able to join them back together and unzip.

copy /b fil1+file2+file3+file4+file5 bigzipfile.zip

If it creates spanned 1.9M zip chunks then you shouldn't need to join them they just need to have name s like file.Z01 file.Z02 etc with the last being file.zip ( I think - havent' had to do that for a while). When you open the last file it reads the others automatically

If it creates 1.9M zips then you can't join them you need to extract each indiviually.

TheExcession

11,669 posts

280 months

Thursday 25th May 2006
quotequote all
Didn't the old pkzip utillity use to have the abillity to split a large zip into chunks so that it could be copied across several floppy disks?

There might be a switch with in winzip to do this.

Have you tried opening just the first zip file, it might automatically go looking for the remaining parts.

zumbruk

7,848 posts

290 months

Thursday 25th May 2006
quotequote all
malman said:
If the software that produces the file creates a big zip then splits it into 1.9M chunks then you should be able to join them back together and unzip.

copy /b fil1+file2+file3+file4+file5 bigzipfile.zip


I suspect you may have put your finger on it there. It used to be the case that MS-DOS put a CTRL-Z on the end of files, then packed up to the next block (512 byte) boundary with whatever happened to be in the buffer at the time. The '/b' switch ('binary') to "copy" told it not to do that. I wonder if Windows is still doing this and hence corrupting the files when they are concatenated back together ... ?

malman

2,258 posts

289 months

Friday 26th May 2006
quotequote all
zumbruk said:
malman said:
If the software that produces the file creates a big zip then splits it into 1.9M chunks then you should be able to join them back together and unzip.

copy /b fil1+file2+file3+file4+file5 bigzipfile.zip


I suspect you may have put your finger on it there. It used to be the case that MS-DOS put a CTRL-Z on the end of files, then packed up to the next block (512 byte) boundary with whatever happened to be in the buffer at the time. The '/b' switch ('binary') to "copy" told it not to do that. I wonder if Windows is still doing this and hence corrupting the files when they are concatenated back together ... ?


Yeah its supposed to auto switch between ascii / binary mode but I'd rather know what its doing rather than guess