首页 > 代码库 > shell脚本之 给PNG图片添加后缀@3x

shell脚本之 给PNG图片添加后缀@3x

 

#!/bin/sh

root_src=$(dirname $(PWD))
echo ${root_src}

image_path=${root_src}/images
echo ${image_path}
# find ${image_path} -name *.png  -exec echo {} \;
# find ${image_path}  -name "*.png" -o -name "*.hhh" -exec echo {} \;
# find ${image_path} -regex *.png\|*.jpg  -exec echo {} \;


pngfiles=`find ${image_path} -name *.png `
suffix2x=@3x.png
suffix3x=@2x.png
for file in $pngfiles
do
    if [[ ${file} =~ ${suffix2x} || ${file} =~ ${suffix3x}  ]]
      then
        echo "${file}不变"

    else
        echo "${file}需要添加@3x"
        mv ${file} "${file%.png}@3x.png"
    fi

done

 

shell脚本之 给PNG图片添加后缀@3x