Skip to content

Instantly share code, notes, and snippets.

@sorokine
Forked from jesseadams/flac2mp3
Created March 31, 2013 20:30
Show Gist options
  • Save sorokine/5281900 to your computer and use it in GitHub Desktop.
Save sorokine/5281900 to your computer and use it in GitHub Desktop.

Revisions

  1. @jesseadams jesseadams created this gist Nov 21, 2010.
    28 changes: 28 additions & 0 deletions flac2mp3
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/bin/bash
    convert_dir=$1
    output_dir=$2
    bitrate=$3

    # Ensure require params are passed in
    if [ -z $convert_dir ] || [ -z $output_dir ];
    then
    echo "Usage: flac2mp3 rip_dir output_dir [bitrate]"
    exit
    fi

    # Default to 320 kbps if bitrate not specified
    if [ -z $bitrate ];
    then
    bitrate=320
    fi

    # Get the list of files to convert
    files=( `find $convert_dir -iname '*.flac' | tr "\n" " "` )

    # Convert each file, one at a time
    for file in ${files[*]}
    do
    flac -dc $file | lame -b $bitrate - $output_dir/`basename $file`.mp3
    done

    echo "Conversions complete!"