Fix braindead and broken way to calculate abase, fixes regression tests on
[mplayer/glamo.git] / TOOLS / subsearch.sh
blobf8e4b4540068276a3e77ff047787c07aacb822b9
1 #!/bin/sh
3 # Collects all the appropriate subtitle files in a given directory and
4 # its subdirectories, no matter what the filename is.
5 # Use this together as: mplayer -sub `subsearch.sh` movie
6 # Author: Alex
9 [ $1 ] && cd `dirname $1`
11 _sub_names=""
13 one_dir_search() {
14 for i in $dir/*
16 case "`echo $i | tr [:upper:] [:lower:]`" in
17 *.sub|*.srt|*.mps|*.txt) _sub_names="$i,$_sub_names" ;;
18 *) ;;
19 esac
20 done
23 dir="."
24 one_dir_search
26 # add subdirectories too
27 for dir in *
29 [ -d $dir ] && one_dir_search
30 done
32 _len="`echo $_sub_names | wc -c`"
33 _len=$((_len-2))
34 echo $_sub_names | cut -b -"$_len"