Unzip to a specific folder

zip

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?

Best Answer

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.

Related Question