Skip to content

Instantly share code, notes, and snippets.

@Ch00k
Created September 4, 2013 09:08
Show Gist options
  • Select an option

  • Save Ch00k/6434573 to your computer and use it in GitHub Desktop.

Select an option

Save Ch00k/6434573 to your computer and use it in GitHub Desktop.
#!/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