echo "+ \"$fname%presentation-32.png%\" Exec exec $pptviewer \"$i\"";;
"jpg" | "png")
echo "+ \"$fname%image-32.png%\" Exec exec $picviewer \"$i\"";;
"avi" | "mkv" | "rm" | "rmvb" | "wmv")
echo "+ \"$fname%video-32.png%\" Exec exec $videoplayer \"$i\"";;
"mp3" | "wma")
echo "+ \"$fname%audio-32.png%\" Exec exec $audioplayer \"$i\"";;
"gz" | "bz2" | "tar" | "zip" | "rar" | "deb" | "rpm")
echo "+ \"$fname%tarball-32.png%\" Exec exec $tarviewer \"$i\"";;
"iso")
echo "+ \"$fname%iso-32.png%\" Exec exec $tarviewer \"$i\"";;
"htm" | "html" | "mht" | "xml")
echo "+ \"$fname%html-32.png%\" Exec exec $browser \"$i\"";;
"exe" | "msi")
echo "+ \"$fname%bin-32.png%\"";;
"ttf")
echo "+ \"$fname%font-32.png%\"";;
*)
if [ -f "$i" ] && [ -x "$i" ];then
echo "+ \"$fname%script-32.png%\" Exec exec $editor \"$i\""
else # 不能识别类型的一律用记事本打开
echo "+ \"$fname%text-32.png%\" Exec exec $editor \"$i\""
fi
;;
esac
fi
done
}
if [ $# -eq 1 ];then
makemenu "$1" "" 1 "MainDir" # 生成主目录菜单,第四个参数仅在此处使用
elif [ $# -eq 2 ] && [ "$1" = "-r" ];then
makemenu "$2" "" 1 "MainDir"
x=1
p=0
queue[0]="$2" # 要生成菜单的主目录入队
while [ $p -lt $x ];do
for i in "${queue[$p]}"/*;do
if [ -d "$i" ];then
queue[$x]="$i"
let x=$x+1
fi
done
let p=$p+1
#if [ $p -lt $x ];then
makemenu "${queue[$p]}" $p $x "" # x是该目录下第一个子目录的位置,注意第四个参数为空
#fi
done
else
echo "Usage: `basename $0` [ -r ] absolute path(without trailing slash)"
fi
原文转自:http://blogread.cn/it/article/6351