wesnoth/utils/find-unused-images
András Salamon d3f71fa607 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.
2005-10-23 14:36:43 +00:00

21 lines
833 B
Bash
Executable File

#!/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