Im completely new to Bash scripting but I've been told, with little help, to create a file that compresses textures into PVR format only if the file has been modified since the last time the script was run. Heres the code I have so far:
# variables
TEXTURE_TOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/texturetool
INPUT_DIR="/Data/Mobile"
OUTPUT_DIR="/Data/iPhone"
IMAGE_GREP="\(.bmp\|.png\)"
OTHER_GREP="\.b3d$"
echo "Starting backup of directory $INPUT_DIR to directory $OUTPUT_DIR"
# cycle through the input directory for images we can compress
echo "Compressing textures!"
for i in $( ls -a "$INPUT_DIR" | grep $IMAGE_GREP );
do
if test "$OUTPUT_DIR/$i.pvr" -nt "$INPUT_DIR/$i"; then
# check to see output's status
echo "Compressing file $i!"
# compress and store in output directory
$TEXTURE_TOOL -m -e PVRTC --bits-per-pixel-2 -o "$OUTPUT_DIR/$i.pvr" -f PVR "$INPUT_DIR/$i"
fi
done
# cycle through the input directory for models we can export
echo "Moving models!"
for i in $( ls -a "$INPUT_DIR" | grep $OTHER_GREP );
do
# check to see output's status
echo "Moving model file $i!"
# cp to output directory
cp "$INPUT_DIR/$i" "$OUTPUT_DIR/$i"
done
Using one of the questions here I tried to do the timestamp checking but I it isnt working and I'm pretty sure its because I dont fully understand the code.
Can anyone suggest what Im doing wrong
Thanks, Michael A