Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

System info:

aggitan@moneque:~$ uname -a
Linux moneque 2.6.32-25-generic #44-Ubuntu SMP Fri Sep 17 20:05:27 UTC 2010 x86_64 GNU/Linux

aggitan@moneque:~$ 7z

7-Zip 9.04 beta  Copyright (c) 1999-2009 Igor Pavlov  2009-05-30
p7zip Version 9.04 (locale=en_US.utf8,Utf16=on,HugeFiles=on,2 CPUs)

I've got a folder that has 68 archives in it ranging from .rar, .ace, & .zip.

I want to extract all of these files using their folder name as the first directory ("Extract here")

If I use file-roller it halts at the first error, there doesn't appear to be an "ignore error" flag for file roller.

If I use 7zip it dumps everything into the current folder and doesn't use clean folders

How can I extract everything into separate folders without spilling everything into the current directory?

share|improve this question
up vote 2 down vote accepted

for i in *; do mkdir "$i.extracted"; (cd "$i.extracted" && 7z x "../$i") || echo "Error with $i"; done

share|improve this answer
Make this for i in *; do mkdir "$i.extracted"; (cd "$i.extracted" && 7z x "../$i"); done. That way, if cd fails for a particular directory, 7z doesn't set to work in the current directory. – Gilles Oct 18 '10 at 12:09
@Gilles: good point, thanks. Also added a error message (hope my brackets are correct) – Tobias Kienzler Oct 18 '10 at 12:11
@Tobias: With the parentheses, you don't need cd ..: the parentheses create a subshell, and the directory change is local to that subshell. – Gilles Oct 18 '10 at 12:16
@Gilles: once again I learned something new, thank you – Tobias Kienzler Oct 18 '10 at 12:19
This did it for me, thank you. I cross posted to askubuntu should I link to this, copy paste your answer or can you post there?… – aggitan Oct 18 '10 at 12:44

Your Answer


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.