#!/bin/bash if [ -z "$1" -o -z "$2" ]; then echo "Usage: $0 --bluray-device|--dvd-device SOMEDIRECTORY" exit 1 fi device_param="$1" device_path="$2" if [ "$device_param" = "--bluray-device" ]; then device_param="-bluray-device" device_scheme="bluray" elif [ "$device_param" = "--dvd-device" ]; then device_param="-dvd-device" device_scheme="dvd" else echo "Unknown device type: $device_param" exit 1 fi mplayer 2> /dev/null \ -noconfig all \ -quiet \ -ao null \ -vo null \ -frames 0 \ -identify \ "$device_param" "$device_path" \ "${device_scheme}://" | \ sed -e 's/ID_\(DVD\|BLURAY\)_TITLE_\([0-9]*\)*_LENGTH=\(.*\)$/\2 \3/;tx;d;:x' | \ sort -n