shell脚本 将非9图和不在黑名单中的png转webp

# !/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!"

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...