Skip to content

Commit

Permalink
Merge pull request arunx2#2 from yomajkel/master
Browse files Browse the repository at this point in the history
I'd like to have your change :)
  • Loading branch information
arunachalam-l committed May 24, 2013
2 parents 1dcea42 + 41c16d7 commit 3dd71dd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions find-unused-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@
echo "<html>"
echo "<h2> Unused resources </h2>"
#usual disclaimer
echo "<i> <b>Note:</b> This scans all the xib, nib files for the images available. Please look for splash screens or other images carefully in the below list which are used in the project definition (pbxproj file)</i> <br>"
echo "<i> <b>Note:</b> This scans all the xib, nib files for the images available. Please look for splash screens or other images carefully in the below list which are used in the project definition (pbxproj file).<br>In order for links to work the report file must be in the same folder as project.</i>"
unusedfiles="";
#initialize the counter
let count=0;
let totalsize=0;
# collect the files needs to be introspected
project=`find $1 -name '*.?ib' -o -name '*.[mh]'`

for i in `find $1 -name "*.png" -o -name "*.jpg"`; do
file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x`
if ! grep -q $file $project; then
unusedfiles="$unusedfiles <br> $i";
# echo $i
let "count = count + 1";
filesize=`stat -f "%z" $i`;
filesizekb=`echo "$filesize 1024.0" | awk '{printf "%.2f", $1 / $2}'`
unusedfiles="$unusedfiles <br> <a href=\"$i\">$i</a> ($filesizekb kb)";
let "count += 1";
let "totalsize += $filesize"
fi
done
#construct body
totalsizekb=`echo "$totalsize 1024.0" | awk '{printf "%.2f", $1 / $2}'`
echo "<body>"
echo "<h3>"
echo "There are $count unused images"
echo "There are $count unused images (total size: $totalsizekb kb)"
echo "</h3>"
echo "<pre>"
#generate body content if there are unused files.
Expand Down Expand Up @@ -57,4 +61,4 @@ fi
echo "</pre>"
echo "</body>"
echo "</html>"
#thats it!
#thats it!

0 comments on commit 3dd71dd

Please sign in to comment.