1234567891011121314151617181920 |
- #! /bin/sh
- read -p "Continue (y/n)? " choice
- case "$choice" in
- y|Y ) echo "yes" ;;
- n|N ) echo "no" && exit 0 ;;
- * ) echo "invalid" && exit 1 ;;
- esac
- # Convert all the PNG and JPEG files to WebP format with 75 quality lossy compression
- # Then delete all the unused JPEG/PNG files
- find ./ -type f -name '*.png' -exec sh -c 'cwebp -q 80 $1 -o "${1%.png}.webp" && rm "${1}"' _ {} \;
- find ./ -type f -name '*.jpg' -exec sh -c 'cwebp -q 80 $1 -o "${1%.jpg}.webp" && rm "${1}"' _ {} \;
- find ./ -type f -name '*.jpeg' -exec sh -c 'cwebp -q 80 $1 -o "${1%.jpeg}.webp" && rm "${1}"' _ {} \;
- find ./ -type f -name '*.gif' -exec sh -c 'cwebp -q 80 $1 -o "${1%.gif}.webp" && rm "${1}"' _ {} \;
- # find ./ -type f -name '*.jpg' -delete ;
- # find ./ -type f -name '*.jpeg' -delete ;
- # find ./ -type f -name '*.png' -delete ;
|