Create a gist now

Instantly share code, notes, and snippets.

Androidプロジェクト(Eclipse版) - 使用していないイメージ画像を削除
#!/bin/sh
if [ $# -ne 1 ]; then
echo "argument error"
exit 1
fi
echo "start"
PROJECT_NAME=$1
IMG_DIRECTORY=${PROJECT_NAME}"/res/drawable-*"
SEARCH_DIRECTORY1=${PROJECT_NAME}"/src"
SEARCH_DIRECTORY2=${PROJECT_NAME}"/res/layout"
SEARCH_DIRECTORY3=${PROJECT_NAME}"/res/menu"
SEARCH_DIRECTORY4=${PROJECT_NAME}"/res/drawable"
SEARCH_FILE1=${PROJECT_NAME}"/AndroidManifest.xml"
use_img_lst=()
unused_img_lst=()
for line in `find ${IMG_DIRECTORY} -type f | sort | uniq`; do
file=`echo ${line} | sed -e 's!^.*/!!' -e 's!.9.png$!!' -e 's!.png$!!' -e 's!.jpg$!!'`
if grep -r ${file} ${SEARCH_DIRECTORY1} ${SEARCH_DIRECTORY2} ${SEARCN_DIRECTORY3} ${SEARCH_DIRECTORY4} ${SEARCH_FILE1} > /dev/null 2>&1; then
echo "use:" $line
use_img_lst=("${use_img_lst[@]}" $line)
else
echo "nonuse:" $line
unused_img_lst=("${unused_img_lst[@]}" $line)
fi
done
echo "export complete [use imagefile list]"
for elem in ${use_img_lst[@]}; do
echo $elem >> use-output.txt
done
echo "export complete [unused imagefile list]"
for elem in ${unused_img_lst[@]}; do
echo $elem >> unused-output.txt
rm -r $elem
done
echo "complete"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment