Bootstrap

webp 批量转换png或jpg

webp 批量转换png或jpg

Mac下无法预览webp文件,用脚本批量转换webp文件为png 或jpg

依赖框架: wedp
1、安装webp brew install webp(先安装homebrew)
2、修改下面root_dir路径即可 转换该目录下所有wedp文件

#!/bin/bash
function getdir(){
compareName='.webp';
for element in `ls $1`
do
dir_or_file=$1"/"$element
if [ -d $dir_or_file ]
then
getdir $dir_or_file
else
# echo ${dir_or_file##*.}
if [ ${dir_or_file##*.} = 'webp' ]
then
newname=${dir_or_file%.*}
dwebp $dir_or_file -o ${newname}".png" #如果要转换成jpg  将png换成jpg即可
rm -f $dir_or_file
echo "dwebp转换 "${dir_or_file}" 到 "${newname}
fi
fi
done
}
root_dir="/Users/wanghuajie/Downloads/qdqtzyx/assets"
getdir $root_dir

;