format-eyevideos.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # usage: ./format-eyevideos.sh [--dry]
  3. if [ "$1" = "" ]; then
  4. MOVE=1
  5. else
  6. echo "***$0: dry-ryn mode"
  7. MOVE=0
  8. fi
  9. for SUB in MLA*
  10. do
  11. for SESS in `find $SUB/session* -d 0`
  12. do
  13. echo ">>> $SESS"
  14. for SIDE in left right
  15. do
  16. DOMAIN="${SIDE}-eye"
  17. if [ -d "$SESS/$DOMAIN" ]; then
  18. FILES=`find $SESS/$DOMAIN/Camera*.avi -d 0`
  19. if [ "$?" -ne "0" ]; then
  20. # no such files
  21. continue
  22. fi
  23. for FILE in FILES
  24. do
  25. 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'`
  26. BASE=`echo $FORMATTED | sed -e 's/_[0-9]\{1,\}.avi//g'`
  27. RUN=`basename $FORMATTED | sed -e 's/[0-9a-zA-Z_\-]\{1,\}_\([0-9]\{1,\}\).avi/\1/g'`
  28. RUNSTR=`printf '%05d\n' $RUN`
  29. NEWFILE="${BASE}_${DOMAIN}_run${RUNSTR}.avi"
  30. if [ "$MOVE" -eq "1" ]; then
  31. mv $FILE $NEWFILE
  32. else
  33. echo $NEWFILE
  34. fi
  35. done
  36. fi
  37. done
  38. done
  39. done