// 查找某类文件,并集中cp 到指定目录
find ./ -type f -name '*.png' -exec cp -fr {} ~/Desktop/xz-temp/ ;
查找不使用的图片
PROJ=`find . -name '*.xib' -o -name '*.[mh]'`
find ./Resources -name "*.png"
|while read line;do
line=`basename $line`
if echo "$line" | grep -q "2x" ; then
iname=${line%%@*}
[ -z "`find ./ ( -name "*.m" -or -name "*.h" )|xargs grep -E "${iname}"`" ] && echo $line;
else
iname=${line%%.*}
[ -z "`find ./ ( -name "*.m" -or -name "*.h" )|xargs grep -E "${iname}"`" ] && echo $line;
fi
done
---
查找不使用的图片
#!/bin/sh
echo "过滤结果如下:" > ~/Desktop/unused_all_images.txt
# 查找这些类型的文件
find $1 -type f -name '*.xib' -o -name '*.[mh]' -o -name '*.json' -o -name '*.sh' > ~/Desktop/tmp_all_files.txt
for png in `find $1 -type f -name '*.png'`
do
# 不过滤 .bundle下的
if [[ "$png" =~ ".bundle" ]]; then
continue
fi
name=`basename $png .png`
empty=""
if [[ "$name" =~ "@2x" ]] || [[ "$name" =~ "@3x" ]]; then
name=${name/@2x/$empty}
fi
#echo "xzoscar:${name}"
isfound=0
while read line
do
if grep "${name}" "${line}"; then
isfound=1
break
fi
done < ~/Desktop/tmp_all_files.txt
if [ $isfound -eq 0 ]; then
echo "$name is not referenced" >> ~/Desktop/unused_all_images.txt
fi
done