title: Unconcatenating files
body: <p>I have a corrupted 7-zip archive that I am extracting manually using <a href="http://sourceforge.net/p/sevenzip/discussion/45798/thread/e34b4a1d/#0c18" rel="nofollow">the method outlined by Igor Pavlov at this link</a>. <strong>An intermediate result is a large file that is a bunch of files <code>cat</code>'ed together that must be separated manually</strong>. I understand that some file formats will need to be extracted manually by a human using discretion (text files, etc.) but many file formats encode the size of the file as part of the file itself (e.g. <code>.zip</code>). Furthermore, some files can be parsed and their size can be deduced with just a little information about the file format (e.g. <code>.pdf</code>). Let's say the large file consists of the following files concatenated together:</p>
  
  <pre><code>Key: &lt;filename&gt;(&lt;contents&gt;)
  
  badfile(aaaaaaaaaaabbbbbbbbbcccccccdddddddd)   -&gt;    zip1.zip(aaaaaaaaaaa)
                                                       badfile2(bbbbbbbbbcccccccdddddddd)
  </code></pre>
  
  <p>I am looking for a program that I can run on a large file (call it <code>badfile</code>) that can determine the type and size of the first logical file (let's say it's a <code>.zip</code> file) contained within and create a new file to hold the contents (e.g. <code>zip1.zip</code> since filenames are lost) and chop the file off the front of <code>badfile</code>. This would allow me to run the program in a loop to extract files with known types and/or pause and let the user handle the difficult cases. Does such a program exist? I know that the *nix command <code>file(1)</code> will do a lot of the work here, but there would be a lot of effort in encoding rules for sizing files (e.g. <code>.pdf</code>) that I would prefer to not duplicate.</p>