Advertisement
Guest User

Untitled

a guest
May 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. DIRECTORY=$1
  4. EXTENSION=$2
  5.  
  6. TIMESTAMP=$(date "+%Y.%m.%d-%H.%M.%S")
  7. LOG="images-$TIMESTAMP.log"
  8. echo [$TIMESTAMP] Initialize >> $LOG
  9.  
  10. #find files by extention (jpg|png)
  11. OCURRENCES=($(find $DIRECTORY -type f -name "*.$EXTENSION"))
  12.  
  13. for file in "${OCURRENCES[@]}"
  14. do
  15. if [ $EXTENSION == "jpg" ]
  16. then
  17. jpegoptim --strip-all $file >> $LOG
  18. else
  19. optipng -o5 $file >> $LOG
  20. fi
  21. done
  22.  
  23. TIMESTAMP=$(date "+%Y.%m.%d-%H.%M.%S")
  24. echo [$TIMESTAMP] Done! >> $LOG
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement