Bash timestamp comparisions

Bash timestamp comparisions

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

What options exist on Mac OS X for software that makes architectural diagrams? [closed]


Word 2008 macro to SVN ADD current document
Doing things only if some files are newer than expected is best achieved with make.

Eclipse RCP on OSX - How to stop logging to syslog?
This is a little more complex to learn but very efficient..
Use rsync to copy only hidden files

Are there any API to turn on DXVA in Mac OSX

Video capture on MacOS


Installing mechanize gem on Mac OS X 10.4.11 gives 'Failed to build gem native extension'
test "$OUTPUT_DIR/$i.pvr" -nt "$INPUT_DIR/$i"; 
Checks to see if $OUTPUTDIR/$i.pvr is newer than $INPUTDIR/$i, I think you want to do it the other way around..
Difference between CFRunLoopRemoveSource and CFRunLoopSourceInvalidate
test "$INPUT_DIR/$i" -nt "$OUTPUT_DIR/$i.pvr"; 
To check to see fi the input is newer than the output..

70 out of 100 based on 50 user ratings 400 reviews