#!/bin/sh
for zip in *.zip
do
dirname=`echo $zip | sed 's/\.zip$//'`
if mkdir "$dirname"
then
if cd "$dirname"
then
unzip ../"$zip"
cd ..
# rm -f $zip # Uncomment to delete the original zip file
else
echo "Could not unpack $zip - cd failed"
fi
else
echo "Could not unpack $zip - mkdir failed"
fi
done
shopt -s globstar
root_directory="."
for zip_file_name in **/*.{zip,sublime\-package}; do
directory_name=`echo $zip_file_name | sed 's/\.\(zip\|sublime\-package\)$//'`
printf "Unpacking zip file \`$root_directory/$zip_file_name\`...\n"
if [ -f "$root_directory/$zip_file_name" ]; then
mkdir -p "$root_directory/$directory_name"
unzip -o -q "$root_directory/$zip_file_name" -d "$directory_name"
# Some files have the executable flag and were not being deleted because of it.
# chmod -x "$root_directory/$zip_file_name"
# rm -f "$root_directory/$zip_file_name"
fi
done