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?

link|improve this question
feedback

1 Answer

up vote 2 down vote accepted

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

link|improve this answer
2  
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
1  
@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? askubuntu.com/questions/8089/… – aggitan Oct 18 '10 at 12:44
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

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