From: fredrik Date: Sun, 10 Jun 2007 00:20:26 +0000 (+0000) Subject: Added findfile. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=25378dd83f0a518cdd0e0935afb1140ed383cb84;p=utils.git Added findfile. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1068 959494ce-11ee-0310-bf91-de5d638817bd --- diff --git a/planime b/planime index edcba1f..5b09f0f 100755 --- a/planime +++ b/planime @@ -1,5 +1,39 @@ #!/bin/sh +isnum() { + grep -xq '[0-9]\+' <<<"$1" +} + +findfile() { + local file tail eq eqt m + for file in "$1"*; do + tail="${file#$1}" + eq="${tail%.*}" + m=n + if [ "${eq%% *}" -eq "$2" ] 2>/dev/null; then + if [[ "$eq" == *\ * ]]; then + eqt="${eq#* }" + else + eqt= + fi + m=y + elif [ "${eq:0:${#2}}" = "$2" ]; then + eqt="${eq:${#2}}" + if [ "${eqt:0:1}" = " " -o -z "$eqt" ]; then + eqt="${eqt# }" + m=y + fi + fi + if [ "$m" = y ]; then + if [ "$eqt" = "$3" -o "$eqt" = "($3)" ]; then + echo "$file" + return 0 + fi + fi + done + return 1 +} + cmdline=(mplayer -fs) while [ "${1:0:1}" = - ]; do