How can I force unzip / zip not to create a subdirectory when I extract it?
If your zip file contains no directory structure or you do not need to preserve it, you can use this:
unzip -j omeka-1.5.1.zip -d omeka
Use a FUSE filesystem that allows you to browse archives like directories, such as AVFS. Use
cp to extract the files to the directory of your choice.
cp -Rp ~/.avfs/tmp/omeka-1.5.1.zip\#/omeka-1.5.1 omeka
Since we're assuming that there is a single toplevel directory in the archive, you can shorten this to
cp -Rp ~/.avfs/tmp/omeka-1.5.1.zip\#/* omeka
This script is not robust, but works in the simple cases:
unzip omeka-1.5.1.zip -d $dest/
if [ `ls $dest | wc -l` == 1 ]; then
mv $dest/$subdir/* $dest/
It just checks to see if there is exactly one subdirectory, and if so, moves everything up out of it then deletes it.