Skip to content

Instantly share code, notes, and snippets.

@davidhuser
Last active July 7, 2017 23:53
Show Gist options
  • Save davidhuser/f468a517cd5e1c2c024fa05d6ef66d6d to your computer and use it in GitHub Desktop.
Save davidhuser/f468a517cd5e1c2c024fa05d6ef66d6d to your computer and use it in GitHub Desktop.
#!/bin/bash
# Flac to MP3 with option recursive, unpack zips first
echo "$PWD"
read -rp "Recursive? y/n - " recursive
for f in $(find . -type f -name '*.zip')
do
unzip -n "$f"
done;
case "$recursive" in
y) find . -type f -name '*.flac' | while read fn; do
echo "$fn"
if flac -cds "$fn" | lame -q 0 -b 320 --silent - "${fn%.*}".mp3; then
rm -fv "${fn}"
fi
done;
;;
n) NO=$(ls -1q *.flac | wc -l)
if [[ $NO -ge 1 ]]
then
for fn in *.flac; do
if [[ -f "$fn" ]]; then
echo "$fn"
if flac -cds "$fn" | lame -q 0 -b 320 --silent - "${fn%.*}".mp3 ; then
rm -fv "${fn}"
fi
fi
done
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment