Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DIRECTORY=$1
- EXTENSION=$2
- TIMESTAMP=$(date "+%Y.%m.%d-%H.%M.%S")
- LOG="images-$TIMESTAMP.log"
- echo [$TIMESTAMP] Initialize >> $LOG
- #find files by extention (jpg|png)
- OCURRENCES=($(find $DIRECTORY -type f -name "*.$EXTENSION"))
- for file in "${OCURRENCES[@]}"
- do
- if [ $EXTENSION == "jpg" ]
- then
- jpegoptim --strip-all $file >> $LOG
- else
- optipng -o5 $file >> $LOG
- fi
- done
- TIMESTAMP=$(date "+%Y.%m.%d-%H.%M.%S")
- echo [$TIMESTAMP] Done! >> $LOG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement