Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a zip archive. The unzip -l command gives this listing:


The root folders are top/subtop for all files. How to extract those files without the two top/subtop folders?

E.g. when I am in /home/myuser/public_html directory, files/1.txt and files2/2.txt shoud be extracted directly to that directory.

I tried unzip top/subtop/* but it created top/subtop directories anyway.

share|improve this question

migrated from Jul 2 '12 at 9:21

This question came from our site for professional and enthusiast programmers.

up vote 4 down vote accepted

Unfortunately, you can't. Your only real option is to just move them after they are extracted.

share|improve this answer
Hmm, good to know. I asked this because a few days ago, when creating an archive, it was adding some paths from above, unintentionally. So there was a problem unzipping them because of the additional top paths. However, I can't repeat this today - today it's working ok, i.e. when in top/subtop directory and doing zip -r * it does not add the top/subtop path as prefix to files path. I think I do exactly the same command, but strangely, results are different, so it is not necessary to strip top directories when unzipping. – camcam Jul 5 '12 at 6:12

You might want to try the tar command, which has a --strip-components feature and can operate on zip files.

share|improve this answer
Does not work with tar (GNU tar) 1.15.1: tar: This does not look like a tar archive tar: Error exit delayed from previous errors – Kevin Panko Jan 6 '14 at 22:05
FreeBSD's tar can handle ZIP-archives. Other tar-implementations aren't as full-featured, unfortunately. – Mikhail T. Apr 25 '14 at 20:30

I used this command to copy all files to my root file directory after Extracting All zipped files, it worked great. Huge time saver:

for /r %f in (00P*) do @copy "%f" 


share|improve this answer
You do realize this is a DOS command, and has nothing to do with a Linux command line, right? – MestreLion Aug 31 '15 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .