Skip to content

Instantly share code, notes, and snippets.

@pearkes
Last active December 18, 2015 14:18

Revisions

  1. pearkes revised this gist Jun 17, 2013. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions flactomp3
    Original file line number Diff line number Diff line change
    @@ -9,16 +9,14 @@
    #
    # flactomp3 DIRECTORY
    #
    # Install:
    #
    # curl -L http://git.io/IrxqdA >> /usr/local/bin/flactomp3; chmod +x /usr/local/bin/flactomp3
    #

    # Fail fast
    set -e

    # Check to see if ffmpeg is kickin it here
    if [ ! -f `type -P` ]; then
    echo "You need to install ffmpeg. (brew/apt-get install ffmpeg)"
    echo "You need to install ffmpeg (brew/apt-get install ffmpeg)"
    exit
    fi

    @@ -30,7 +28,7 @@ fi

    # Are there flac files in there?
    if [ `ls -1 $1/*.flac 2>/dev/null | wc -l` = 0 ]; then
    echo "There aren't any flac files in `pwd $1`"
    echo "There aren't any flac files in `pwd`/$1"
    exit
    fi

  2. pearkes revised this gist Jun 17, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion flactomp3
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,9 @@
    #
    # flactomp3 DIRECTORY
    #
    #
    # Install:
    #
    # curl -L http://git.io/IrxqdA >> /usr/local/bin/flactomp3; chmod +x /usr/local/bin/flactomp3

    # Fail fast
    set -e
  3. pearkes created this gist Jun 17, 2013.
    42 changes: 42 additions & 0 deletions flactomp3
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #!/bin/sh

    # Converts a directory of .flac files to the proprietary and lossy
    # .mp3 format, retaining meta data.
    #
    # Note: Requires ffmpeg (brew/apt-get install ffmpeg)
    #
    # Use:
    #
    # flactomp3 DIRECTORY
    #
    #

    # Fail fast
    set -e

    # Check to see if ffmpeg is kickin it here
    if [ ! -f `type -P` ]; then
    echo "You need to install ffmpeg. (brew/apt-get install ffmpeg)"
    exit
    fi

    # Is the first argument there, is it a dir?
    if [ ! $1 ] || [ ! -d $1 ]; then
    echo "Requires directory as first argument"
    exit
    fi

    # Are there flac files in there?
    if [ `ls -1 $1/*.flac 2>/dev/null | wc -l` = 0 ]; then
    echo "There aren't any flac files in `pwd $1`"
    exit
    fi

    echo "Starting conversion..."

    for file in $1/*.flac;
    do
    ffmpeg -i "$file" -ab 320k -map_metadata 0 "${file%.*}.mp3";
    done

    echo "Finished"