1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/bin/bash
- # usage: ./format-eyevideos.sh [--dry]
- if [ "$1" = "" ]; then
- MOVE=1
- else
- echo "***$0: dry-ryn mode"
- MOVE=0
- fi
- for SUB in MLA*
- do
- for SESS in `find $SUB/session* -d 0`
- do
- echo ">>> $SESS"
- for SIDE in left right
- do
- DOMAIN="${SIDE}-eye"
- if [ -d "$SESS/$DOMAIN" ]; then
- FILES=`find $SESS/$DOMAIN/Camera*.avi -d 0`
- if [ "$?" -ne "0" ]; then
- # no such files
- continue
- fi
- for FILE in FILES
- do
- FORMATTED=`echo $FILE | sed -e 's/\[//g' -e 's/\]//g' -e 's/Camera[0-9]-//g' -e 's/_[0-9]\{6,6\}_/_/g' -e 's/\([0-9]\{4,4\}\)\([0-9]\{2,2\}\)\([0-9]\{2,2\}\)_MLA\([0-9]\{1,\}\)_/MLA\4_session\1-\2-\3-001_/g'`
- BASE=`echo $FORMATTED | sed -e 's/_[0-9]\{1,\}.avi//g'`
- RUN=`basename $FORMATTED | sed -e 's/[0-9a-zA-Z_\-]\{1,\}_\([0-9]\{1,\}\).avi/\1/g'`
- RUNSTR=`printf '%05d\n' $RUN`
- NEWFILE="${BASE}_${DOMAIN}_run${RUNSTR}.avi"
- if [ "$MOVE" -eq "1" ]; then
- mv $FILE $NEWFILE
- else
- echo $NEWFILE
- fi
- done
- fi
- done
- done
- done
|