#!/bin/bash -e # Convert files into an appropriate format for my MP3 player. # Adam Sampson if [ "$1" = "--file" ]; then temp=/var/tmp/syncp.$$.wav trap "rm -f $temp" 0 shift src="$1" [[ "$src" =~ (.*)"."([^"."]*) ]] base=${BASH_REMATCH[1]} ext=${BASH_REMATCH[2]} if ! [ -e "$src" ]; then exit 0 fi destogg="$base.ogg" destmp3="$base.mp3" if [ -e "$destogg" -o -e "$destmp3" ]; then exit 0 fi echo "Converting $src -> $destmp3" if [ -n "$DRYRUN" ]; then exit 0 fi case $ext in flac) flac -d -o "$temp" "$src" ;; *) ffmpeg -i "$src" -f wav "$temp" ;; esac #oggenc -q3 -o "$destogg" "$temp" lame -h -V6 "$temp" "$destmp3" exit 0 fi cd ${1:-/n/stuff/radio/new} parallel -q -- "$0" --file ::: *.mp2 *.flac *.aac *.flv *.m4a