#!/bin/sh

if [ ! $1 ];then
 echo 'Usage: # dir2tgz <name of directory>'
 exit 1
fi

DIRNAME="`echo -n $1 | sed -e 's%/$%%'`"
DIRNAME="`basename $DIRNAME`"
if [ ! -d $DIRNAME ];then
 echo "Error: $DIRNAME not found. Must open terminal in same directory."
 exit 1
fi

echo "Converting directory $DIRNAME to $DIRNAME.tar.gz..."

tar -c -f ${DIRNAME}.tar ${DIRNAME}/

gzip ${DIRNAME}.tar

sync
echo "Done"
