Created
April 9, 2013 08:06
-
-
Save stonyw/5343868 to your computer and use it in GitHub Desktop.
The shell to find unused images in iOS project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shell for finding unused images in iOS project | |
Source: | |
http://stackoverflow.com/questions/6113243/how-to-find-unused-images-in-an-xcode-project | |
Version 1: | |
#!/bin/sh | |
PROJ=`find . -name '*.xib' -o -name '*.[mh]' -o -name '*.storyboard' -o -name '*.mm'` | |
for png in `find . -name '*.png'` | |
do | |
name=`basename -s .png $png` | |
name=`basename -s @2x $name` | |
if ! grep -q $name $PROJ; then | |
echo "$png" | |
fi | |
done | |
Version 2: | |
#!/bin/bash | |
for i in `find . -name "*.png" -o -name "*.jpg"`; do | |
file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x` | |
result=`ack -i "$file"` | |
if [ -z "$result" ]; then | |
echo "$i" | |
fi | |
done | |
# Ex: to remove from git | |
# for i in `./script/unused_images.sh`; do git rm "$i"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment