I want to unzip the contents of a zipfile called mine.zip into /yours/ but when I do it using the -d flag it keeps going into /yours/crap/ etc which is not I want

Is there a way to do this?


You can flatted the entire contents of the zip file using cd /yours && unzip -j /path/to/mine.zip. The -j option is called "junk paths" and just dumps each file into the current directory instead of extracting any directory structure.

To be more exactly than that, i.e. extracting directory structures except for the top one, you will need to know the name of the folder inside the zip that you want to skip creating and specifically ask unzip to extract the contents of that folder.

Unfortunately unzip is not a flexable as tar with it's various strip folder path options that it can handle for gzip, bzip2, lzip and other compression formats.

| improve this answer | |
  • I'm aware of that option, but its not what I'm looking for though. I need the folder structure to stay intact ... I just need the 'parent folder' name changed – concept47 May 6 '11 at 18:22
  • I just looked into using p7zip's 7z that also handles normal zips nicely, but it has the same to extract options, flatted everything or keep everything. I think you are going to have to script this yourself. unzip mine.zip; mv stuff/* ./; rmdir stuff – Caleb May 6 '11 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.