Skip to content

Instantly share code, notes, and snippets.

@nacho4d
Created November 14, 2011 06:33
Show Gist options
  • Save nacho4d/1363389 to your computer and use it in GitHub Desktop.
Save nacho4d/1363389 to your computer and use it in GitHub Desktop.
[Shell] Zips a file - To be used with Automator to create a short cut for the task
#! /bin/sh
INFILE=$1
ZIP=".zip"
OUTFILE=$INFILE$ZIP
if [ -f "$INFILE" ]; then
echo "Compressing file: $INFILE"
COUNTER=0
while [ -f $OUTFILE ];
do
COUNTER=$((COUNTER+1))
OUTFILE="$INFILE$COUNTER$ZIP"
#echo "calculating... $OUTFILE"
done
echo "Output path: $OUTFILE"
zip $OUTFILE $INFILE
exit 0
else
echo "No file at path: $INFILE"
exit -1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment