Skip to content

Instantly share code, notes, and snippets.

@eggc
Created January 27, 2015 07:55
Show Gist options
  • Save eggc/e6a51a8ebcd61d4cbe85 to your computer and use it in GitHub Desktop.
Save eggc/e6a51a8ebcd61d4cbe85 to your computer and use it in GitHub Desktop.
cue, img -> mp3
#!/bin/bash
# img , cue があるディレクトリでこのスクリプトを実行すると mp3 で抽出する。
# 予め bchunk, lame をインストールする必要がある。brew を使うと楽。
IMG_NAME=(*.img)
CUE_NAME=(*.cue)
BASE_NAME=${IMG_NAME%.*} # cut extension
# ${IMG_NAME[@]} と書くのは、空白文字を許すため。
if [ -f "${IMG_NAME[@]}" ] && [ -f "${CUE_NAME[@]}" ]
then
# bchunk コマンドで img と cue を結合して wav で出力する。
bchunk -w "$IMG_NAME" "$CUE_NAME" "$BASE_NAME"
# lame コマンド で wav を mp3 に変換する。
for WAV_FILE in *.wav
do
lame -b256 -h "$WAV_FILE"
rm "$WAV_FILE"
done
mkdir "$BASE_NAME"
mv *.mp3 "$BASE_NAME"
else
echo "*.cue and *.img are not found."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment