killermist

flac2mp3.sh

Nov 21st, 2020
696
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. for source in ./*.flac; do
  4.   # give output correct extension
  5.   DESTINATION="${source[@]/%flac/mp3}"
  6.  
  7.   # get the tags
  8.   ARTIST=$(metaflac "$source" --show-tag=ARTIST | sed s/.*=//g)
  9.   TITLE=$(metaflac "$source" --show-tag=TITLE | sed s/.*=//g)
  10.   ALBUM=$(metaflac "$source" --show-tag=ALBUM | sed s/.*=//g)
  11.   GENRE=$(metaflac "$source" --show-tag=GENRE | sed s/.*=//g)
  12.   TRACKNUMBER=$(metaflac "$source" --show-tag=TRACKNUMBER | sed s/.*=//g)
  13.   DATE=$(metaflac "$source" --show-tag=DATE | sed s/.*=//g)
  14.  
  15.   # stream flac into the lame encoder
  16.   flac -c -d "$source" | lame -V0 --add-id3v2 --pad-id3v2 --ignore-tag-errors \
  17.     --ta "$ARTIST" --tt "$TITLE" --tl "$ALBUM"  --tg "${GENRE:-12}" \
  18.     --tn "${TRACKNUMBER:-0}" --ty "$DATE" - "$DESTINATION"
  19. done
RAW Paste Data