flacfix script, cpm completion update, newsboat urls, new install_clean patch
[dotfiles.git] / shell / .local / bin / flacfix
1 #!/bin/bash
2
3 if [ "$#" -eq 0 ]
4 then
5 echo "Usage: $0 flacfile [flacfile [flacfile ...]]" >&2
6 exit 1
7 fi
8
9 while [ "$#" -ge 1 ];
10 do
11 samplerate="$(metaflac --show-sample-rate "$1")"
12 bitdepth="$(metaflac --show-bps "$1")"
13 if ! [ "$samplerate" = 44100 -o "$samplerate" = 4800 -a $bitdepth = 16 ]
14 then
15 tfile="$(mktemp --tmpdir --suffix=.flac)"
16 sox "$1" -r 44100 -b 16 "$tfile"
17 mv -v "$tfile" "$1"
18 fi
19 shift
20 done