Created
September 4, 2013 09:08
-
-
Save Ch00k/6434573 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| if | |
| [[ "$#" != 2 ]] | |
| then | |
| echo "Usage: $0 <source_dir> <dest_dir>" | |
| exit 1 | |
| fi | |
| if | |
| builtin command -v zip >/dev/null | |
| then | |
| _zip=zip | |
| else | |
| echo "zip is not found on your system. Please install zip to run this script" | |
| fi | |
| [[ -d "$1" ]] || | |
| { | |
| echo "Source directory does not exist" | |
| exit 1 | |
| } | |
| [[ -d "$2" ]] || | |
| { | |
| echo "Destiantion directory does not exist" | |
| exit 1 | |
| } | |
| _source_dir="$1" | |
| _dest_dir="$2" | |
| _filename="$(basename $1)" | |
| _dirname="$(dirname $1)" | |
| echo "Archiving $1 as $2/$_filename.zip" | |
| cd $_dirname | |
| $_zip -q "$2/$_filename.zip" -r "$_filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment