Skip to content

Instantly share code, notes, and snippets.

@majioa
Created October 1, 2012 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save majioa/3811161 to your computer and use it in GitHub Desktop.
Save majioa/3811161 to your computer and use it in GitHub Desktop.
Bash .bashrc sample
# function to convert an mp3 to an ogg file
function mp3_to_ogg {
mp3=$1
wav=$(echo "$mp3"|sed "s/mp3$/wav/i")
ogg=$(echo "$mp3"|sed "s/mp3$/ogg/i")
artist=$(mp3info -p "%a\n" $mp3)
comment=$(mp3info -p "%c\n" $mp3)
genre=$(mp3info -p "%g\n" $mp3)
album=$(mp3info -p "%l\n" $mp3)
track=$(mp3info -p "%n\n" $mp3)
tracktitle=$(mp3info -p "%t\n" $mp3)
year=$(mp3info -p "%y\n" $mp3)
mpg123 -w "$wav" "$mp3"
oggenc "$wav" --utf8 -a "$artist" -G "$genre" -l "$album" -t "$tracktitle" -N "$track" -d "$year" \
-c "$comment" -o "$ogg"
rm -f "$wav"
}
# function to convert all mp3 files to ogg format in specified or current folder
function all_mp3_to_ogg {
dir=$1
[ -n "$dir" ] || dir=.
find $dir -iregex ".*mp3" | while read i
do
mp3_to_ogg "$i"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment