If an archive contains several files in the root directory, I'd like to create a directory named after the file name (without extension). If an archive contains just a directory, then I'd like to simply extract it. Assume I have the following archive:
# file: withdir.zip
somedir/alpha
somedir/beta
somedir/gamma
If I extract it in the current directory I'd like to have it simply extracted
(unzip withdir.zip
):
somedir/alpha
somedir/beta
somedir/gamma
Now assume the following archive:
# file: nodir.zip
alpha
beta
gamma
When I run unzip nodir.zip
I end up cluttering the current directory
with the three files:
alpha
beta
gamma
I'd rather run unzip -d nodir nodir.zip
:
nodir/alpha
nodir/beta
nodir/gamma
If I use nautilus and right click on “Extract Here”. It behaves exactly as it
should. But unfortunately I haven't found a command line switch for unzip
or
7z
which yield the same behaviour. How to achieve that? Are there other tools I can use instead
(no GUI)?