Script to identify possibly unused images.

Run inside the top level source directory to produce a pseudo-diff
highlighting possible unused images.  Many image filenames (eg. for
terrains) are actually constructed by the code, so these are not
actually unused.
This commit is contained in:
András Salamon 2005-10-23 14:36:43 +00:00
parent 7cc5718c4a
commit d3f71fa607

20
utils/find-unused-images Executable file
View file

@ -0,0 +1,20 @@
#!/bin/sh
# attempt to identify images that are not used
# this is a helper script for the Battle for Wesnoth project
# see http://www.wesnoth.org/
# this script is distributed on the same terms as Battle for Wesnoth itself
# note that many images (eg. for terrains) are actually referenced,
# but the image filename is constructed programmatically so it's not
# easy to auto-detect these
TM=tmp-all.$$
TMU=tmp-used.$$
find images -name '*.png' -print | sort -u | sed -e 's/^images\///' > $TM
fgrep -r .png data | sed -e 's/.* \([^ ]*\.png\)/\1/' -e 's/.*=\([^ ]*\.png\)/\1/' -e 's/(\([^)]*\))/\1/' -e 's/\"\(.*\)\"/\1/' -e 's/\.png .*/.png/' -e 's/\.png\".*/.png/' -e 's/\"//' -e 's/[ ]*//g' -e 's/:[0-9]*//g' -e 's/,$//' -e 's/,/ /g' | perl -p -e 's/ /\n/g' | sort -u > $TMU
diff -u0 $TMU $TM | grep -v '^@@'
rm -f $TM $TMU