【发布时间】:2009-08-10 14:45:45
【问题描述】:
我对 Bash 脚本完全陌生,但有人告诉我,在没有什么帮助的情况下,只有在文件自上次运行脚本后已被修改时,才创建一个将纹理压缩为 PVR 格式的文件。这是我到目前为止的代码:
# 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
使用此处的一个问题,我尝试进行时间戳检查,但它不起作用,我很确定它是因为我不完全理解代码。
谁能建议我做错了什么
谢谢,迈克尔 A
【问题讨论】: