Last active
May 5, 2016 09:58
-
-
Save skatsuta/3c93158c5f765c82af24 to your computer and use it in GitHub Desktop.
Zip each directory inside a given directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Show help | |
if [[ $1 = '--help' || $1 = '-h' ]]; then | |
echo "Usage: $0 [TARGET_DIR]" | |
echo "Zip each directory inside TARGET_DIR. If no argument is given, the current directory is regarded as TARGET_DIR." | |
exit 1 | |
fi | |
# Zip each directory inside the given directory | |
TARGET_DIR=${1:=.} | |
cd "$TARGET_DIR" | |
for i in *; do | |
if [[ -d "$i" ]]; then | |
zip -r "$i".zip "$i" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment