# !/bin/bash # function: convert all png images file (except for ".9.png")in the current directory and subdirectories to webp format echo "Starting convert images format,please wait a minite..." con="\.9\.png" extra=`cat extra` for var in `find . -name "*.png"`; do flag=1 fileName=${var##*/} file=${fileName%%.*} for ex in $extra; do if [ "$file" = "$ex" ]; then # echo find $ex = $file flag=0 break fi done if [ "$flag" -eq 0 ]; then continue fi if [[ $var =~ $con ]]; then echo $var " will not be compressed" else echo $var cwebp -q 70 $var -o ${var%.*}.webp rm $var fi done echo "Convert task complete!"