File: dirtomenu-recursive

package info (click to toggle)
ude 0.2.9b-2.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,788 kB
  • ctags: 2,092
  • sloc: ansic: 15,342; sh: 4,785; makefile: 672; yacc: 288; sed: 16
file content (35 lines) | stat: -rwxr-xr-x 936 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# by Jaime "el mono" Silva <mono@andromeda.utp.edu.co>
#
# this script is based in the script "dirtomenu" maded by Adam Sampson
# this one searches recursivelly the directory and avoids directories
# that do not contain the wanted kind of files. This one can also handle
# spaces in the file names.
# ********* IMPORTANT *********
# Note that in this script the command is the second parameter and the
# file extension is the third
# *****************************
# first argument: directory
# second argument: command to open
# third argument: suffix or '' for any suffixes

for x in $1/* ; do
    if [ -d $x ]; then
	no_cont=""
	for i in $x/*$3; do
	    if [ ! -e $i ]; then
		no_cont="yes"
	    fi
	done
	if [ -z "$no_cont" ]; then
	    echo "SUBMENU \"$(basename "$x")\" {"
	    $0 $x $2 $3
	    echo "}"
	fi
    fi
done

echo "LINE;"
for x in $1/*$3 ; do
    echo "ITEM \"$(basename "$x" $3)\":\"$2 \\\"$x\\\"\";"
done