Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 /your/crap/ etc which is not I want

Is there a way to do this?

share|improve this question

1 Answer 1

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.

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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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