Skip to content

Instantly share code, notes, and snippets.

@include
Created July 4, 2013 10:55
Show Gist options
  • Select an option

  • Save include/5926767 to your computer and use it in GitHub Desktop.

Select an option

Save include/5926767 to your computer and use it in GitHub Desktop.

Revisions

  1. include created this gist Jul 4, 2013.
    28 changes: 28 additions & 0 deletions flacamos.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    #!/bin/bash
    # A Shell Script To Convert All .flac Files To .MP3 Format
    # Note: I found this script somewhere on usenet and I've modified it for my needs
    METAFLAC=/usr/local/bin/metaflac
    FLAC=/usr/local/bin/flac
    #ID3=/usr/bin/id3
    LAME=/usr/local/bin/lame
    FIND=/usr/bin/find

    t=$(${FIND} . -type f -iname "*.flac")
    if [ "$t" == "" ]
    then
    echo "There are no *.flac file in $(pwd) directory"
    exit 1
    fi

    for f in *.flac
    do
    OUTF=$(echo "$f" | sed s/\.flac$/.mp3/g)
    ARTIST=$(${METAFLAC} "$f" --show-tag=ARTIST | sed s/.*=//g)
    TITLE=$(${METAFLAC} "$f" --show-tag=TITLE | sed s/.*=//g)
    ALBUM=$(${METAFLAC} "$f" --show-tag=ALBUM | sed s/.*=//g)
    GENRE=$(${METAFLAC} "$f" --show-tag=GENRE | sed s/.*=//g)
    TRACKNUMBER=$(${METAFLAC} "$f" --show-tag=TRACKNUMBER | sed s/.*=//g)
    DATE=$(${METAFLAC} "$f" --show-tag=DATE | sed s/.*=//g)
    $FLAC -c -d "$f" | $LAME -m j -q 0 --vbr-new -V 0 -s 44.1 - "$OUTF"
    # $ID3 -t "$TITLE" -T "${TRACKNUMBER:-0}" -a "$ARTIST" -A "$ALBUM" -y "$DATE" -g "${GENRE:-12}" "$OUTF"
    done