~q3cpma/mus

ref: e99afe099fd0b6cf6a4cce58902c9612ecd9fca9 mus/mus_album_find -rwxr-xr-x 1.5 KiB
e99afe09q3cpma Finish build.sh and README, move TODO to root 1 year, 1 month ago
                                                                                
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Dependencies:
# Portability:  GNU, *BSD
#+-------------+-----+---------+--------+--------------+---------+-------+---------+-------+-----+------+-------+-------+
#| cmd\OS      | GNU | OpenBSD | NetBSD | DragonflyBSD | FreeBSD | MacOS | Illumos | HP-UX | AIX | IRIX | Tru64 | POSIX |
#+-------------+-----+---------+--------+--------------+---------+-------+---------+-------+-----+------+-------+-------+
#| readlink -f | o   | o       | o      | o            | o       |       |         |       |     |      |       |       |
#+-------------+-----+---------+--------+--------------+---------+-------+---------+-------+-----+------+-------+-------+
# o: supported, X: different behaviour
set -eu
rpath_share=$(dirname -- "$0")
. "$rpath_share"/mus_util.sh


if [ $# -eq 1 ] && [ "$1" = "-h" ]
then
	cat <<EOF | text_format
**NAME**
    $(basename -- "$0") - Album finder

**SYNOPSIS**
    $(basename -- "$0") [**-h**] [__MUSIC_DIR__]...

**DESCRIPTION**
    Search all __MUSIC_DIR__s for albums and list them on stdout, newline
    separated. If no __MUSIC_DIR__ is given, \$__MUS_MUSIC_DIR__ is used. All
    directories in __MUSIC_DIR__ with a relative depth of 2 are considered as
    album directories.

**OPTIONS**
    **-h**
        Print this notice and exit.

**ENVIRONMENT**
    __MUS_MUSIC_DIR__
        Music directory. Defaults to \$HOME/Music.

EOF
	exit 1
fi

[ $# -eq 0 ] && set -- "${MUS_MUSIC_DIR:-$HOME/Music}"

for i
do
	requirefile -d "$i"
	i=$(readlink -f -- "$i")
	find -- "$i" -type d -path "$i/*/*" -print -prune
done