domingo, 28 de outubro de 2012

Script to play a series of video files

#!/bin/bash

while true; do
 
  FILE_TO_PLAY=`ls /directory/whatever_*.mkv | sort | sed 1q`
 
  if [ -z "$FILE_TO_PLAY" ]; then
    echo "No more files!"
    exit 1
  fi
 
  ACTION=`echo 'Play
Move away' | zenity --list --column=Options --text="$FILE_TO_PLAY" 2> /dev/null`
  CODE=$?
 
  if [ 0 != $CODE ]; then
    echo "Goodbye"
    exit 0
  fi
 
  case "$ACTION" in
    "Play"|"")
      echo "Selected to play $FILE_TO_PLAY"
      mplayer -fs "$FILE_TO_PLAY"
      ;;
    "Move away")
      if zenity --question --text="Are you sure you want to move the file $FILE_TO_PLAY ?"; then
        echo "Selected to delete $FILE_TO_PLAY"
        echo mv "$FILE_TO_PLAY" "/directory/done/"
        mv "$FILE_TO_PLAY" "/directory/done/"
      fi
      ;;
  esac

done