#!/bin/sh
command -v convert >/dev/null 2>&1 || { echo >&2 "I require imagemagick but it's not installed.  Aborting."; exit 1; }
command -v apng2gif >/dev/null 2>&1 || { echo >&2 "I require apng2gif but it's not installed.  Aborting."; exit 1; }
command -v gif2png >/dev/null 2>&1 || { echo >&2 "I require gif2png but it's not installed.  Aborting."; exit 1; }
command -v sed >/dev/null 2>&1 || { echo >&2 "I require sed but it's not installed.  Aborting."; exit 1; }
read -p "Please enter your new color in HEX(eg. #ffffff for white) " NEWCOLOR
echo "This may take a while"
#change color in all textfiles
find . -type f -exec sed -i 's/#a5e12d/'$NEWCOLOR'/g' {} \;
#change color in all images
for name in `find -wholename "*.gif"`;do gif2png "$name" && convert -define png:format=png32 `echo $name|sed 's/gif/png/g'` -fill "$NEWCOLOR" -opaque "#a5e12d" `echo $name|sed 's/gif/png/g'` && apng2gif `echo $name|sed 's/gif/png/g'` && rm `echo $name|sed 's/gif/png/g'`;done;
echo "done"
