3 # Copyright © 2009 Nick Bowler
5 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
6 # This is free software: you are free to do what the fuck you want to.
7 # There is NO WARRANTY, to the extent permitted by law.
10 while getopts 's' opt $@; do
19 if [[ $# == 0 ]]; then
20 printf 'usage: %s [-s] directory [directory ...]\n' $0
24 alias mfind='find $@ -type f'
25 flac=`mfind -name '*.flac' | wc -l`
26 vorbis=`mfind -name '*.ogg' | wc -l`
27 mp3=`mfind -name '*.mp3' | wc -l`
28 total=$((flac+vorbis+mp3))
30 if [[ $total == 0 ]]; then
35 printf '%d tracks: %d (%.1f%%) flac, %d (%.1f%%) vorbis, %d (%.1f%%) mp3.\n' \
37 $flac $((100.0*flac /total)) \
38 $vorbis $((100.0*vorbis/total)) \
39 $mp3 $((100.0*mp3 /total))
41 if [[ $sizes == 1 ]]; then
42 alias getsize="du -mc --files0-from=- | sed -n '\$s/\ttotal$//p'"
43 float totalsize=`mfind -print0 | getsize`
44 float flacsize=`mfind -name '*.flac' -print0 | getsize`
45 float vorbissize=`mfind -name '*.ogg' -print0 | getsize`
46 float mp3size=`mfind -name '*.mp3' -print0 | getsize`
48 if [[ $totalsize -gt 4000 ]]; then
49 printf 'size: %.1fG total, %.1fG flac, %.1fG vorbis, %.1fG mp3.\n' \
52 $((vorbissize/1024)) \
55 printf 'size: %.1fM total, %.1fM flac, %.1fM vorbis, %.1fM mp3.\n' \