Skip to content
shell
#!/bin/bash

# 使用需谨慎!!!
# 使用需谨慎!!!
# 使用需谨慎!!!

# 资源目录
assetPath=$1
# src目录
srcPath=$2

imgList=""
length=0

for i in $(find $assetPath -name *.png -o -name *.jpg);do
  # 提取图片名称不包含@3x和扩展名
  file=$(basename -s .png $i | sed 's/@[0-9]x//g')

  if ! grep -q -r $file $srcPath;then
    echo -e "\033[31m$file not used \033[0m"
    imgList=${imgList}"|"${file}
    length=$[$length + 1]
    # 需要删除文件时,去除注释
    # rm $i
  # else
  #   echo "$file is used";
  fi
done

echo "一共有 ${length} 张图片未使用,正则表达式为 ${imgList:1}"