-alias mfind='find $@ -type f'
-flac=`mfind -name '*.flac' | wc -l`
-vorbis=`mfind -name '*.ogg' | wc -l`
-mp3=`mfind -name '*.mp3' | wc -l`
-total=$((flac+vorbis+mp3))
+# Normalize target names.
+targets=()
+for arg in $@; do
+ case $arg in
+ /*) targets+=$arg ;;
+ *) targets+=./$arg ;;
+ esac
+done
+
+# Simple wrapper around find to search for ordinary files in the target
+# directories.
+mfind() {
+ find $targets -type f $@
+}
+
+# Simple ngettext wrapper that should work even if ngettext is not installed.
+ngettext() {
+ command ngettext $@ 2>/dev/null && return 0;
+
+ while [[ $# -gt 3 ]]; do shift; done
+ case $3 in
+ 1) printf '%s\n' "$1" ;;
+ *) printf '%s\n' "$2" ;;
+ esac
+}
+
+# Get the total size (in mebibytes) of a list of files specified on standard
+# input. The input is expected to be in the format of find -print0.
+getsize() {
+ du -mc --files0-from=- | sed -n '$s/\ttotal$//p'
+ (exit ${${pipestatus%0}[1]})
+}
+
+formats=(flac flac ogg vorbis opus opus mp3 mp3)
+total=0
+for ext name in $formats; do
+ typeset $ext=`mfind -name \*.$ext | wc -l`
+ total=$((total + $ext))
+done