-
Notifications
You must be signed in to change notification settings - Fork 3
/
backup-audio
executable file
·108 lines (91 loc) · 2.22 KB
/
backup-audio
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
# Backup a collection of Ogg audiofiles to a set of DVDs. -*- sh -*-
# Copyright (C) 2008 Werner Koch
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
# Default values
PGM="backup-audio"
PGM_VERSION="0.1"
LC_ALL=C
dryrun=no
# Helper constants
tick='`'
# Parse the options
prev=
while [ $# -gt 0 ]; do
arg="$1"
case $arg in
-*=*) optarg=$(echo "X$arg" | sed -e '1s/^X//' -e 's/[-_a-zA-Z0-9]*=//')
;;
*) optarg=
;;
esac
if [ -n "$prev" ]; then
eval "$prev=\$arg"
prev=
shift
continue
fi
case $arg in
--version)
echo "$PGM $PGM_VERSION"
exit 0
;;
--help|-h)
cat <<EOF
Usage: $PGM [options] [arguments]
Backup a collection of audio files to a set of DVDs
Options:
-n, --dry-run Do not create any output
Example:
$PGM /var/home/foo/audio-collection
EOF
exit 0
;;
--dry-run|-n)
dryrun=yes
;;
-*)
echo "$PGM: invalid option $tick$arg'" >&2
exit 1
;;
*)
break
;;
esac
shift
done
if [ -n "$prev" ]; then
echo "$PGM: argument missing for option $tick$prev'" >&2
exit 1
fi
if [ $# != 1 ]; then
echo "usage: $PGM <directory>" >&2
exit 1
fi
sourcedir="$1"
find $sourcedir -mindepth 2 -maxdepth 2 -type d -print0 | xargs -0 du -ms \
| awk '
{ sum += $1
print $0
if (sum > 4300) {
print "-----"
print sum, " total"
sum = 0
dvdcount++;
}
}
END { print "number of DVD required: " dvdcount }
'