Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created November 16, 2013 05:22
Show Gist options
  • Save patrickkettner/7496302 to your computer and use it in GitHub Desktop.
Save patrickkettner/7496302 to your computer and use it in GitHub Desktop.
#!/bin/bash
ASSET_PATH=$1
t="$(date +%s)"
if [ ! -d $ASSET_PATH ] && ( echo $ASSET_PATH not found && exit 1 )
hash zopfli 2>/dev/null || (echo zopfli needs to be installed && exit 1)
find $ASSET_PATH -type f | xargs -P 99 zopfli
# Remove any compressed file that was actually larger than the original
for FILE in $(find $ASSET_PATH -name *.gz ); do
if [ $( stat -c%s $FILE) -ge $( stat -c%s ${FILE%.*}) ]; then
rm $FILE
fi;
done;
t="$(($(date +%s)-t))"
echo "time in seconds: ${t}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment