APE转MP3 + gb2312问题
发表于 : 2010-05-26 23:10
于是咱在学bash script
所以咱写了个ape2mp3的脚本
这个 是可以处理多个ape和cue的 .. 不过还没写好
这个处理一个APE和一个CUE基本完成了 。。 不过有一个问题就是要输入绝对路径 ..
第一就是read第一个读取的变量是ape文件的path
不过在运行的时候不能用tab只能写绝对路径
第二个就是如果有多个APE和CUE文件会很麻烦 ..
不过我大概想到用for来改了
最后就是有一些gb2312编码的cue文件
不过我用什么指令转换到utf-8都继续呈现乱码
比如
比如说下个的这个cue文件 ..
cue还是问题
所以咱写了个ape2mp3的脚本
这个 是可以处理多个ape和cue的 .. 不过还没写好
代码: 全选
#!/bin/bash
apelist=$(ls | grep ape$)
#echo -e $apelist
echo "$apelist" | while read apefile
do
echo -e "$apefile"
wavlist="$(echo $apefile | sed 's/ape/wav/g')"
echo -e $wavlist
mac "$apefile" "$wavlist" -d
echo "$wavlist" | while read wavfile
do
lame -h -b 320 "$wavfile"
done
mp3list=$( echo $wavlist | sed 's/wav/wav.mp3/g')
echo -e $mp3list
cuelist=$(echo $apefile | sed 's/ape/cue/g')
echo -e $cuelist
mp3splt -c "$cuelist" -o @b.@n.@t "$mp3list"
rm "$mp3list"
cuetag "$cuelist" "./*.mp3"
done
mp3dir=$(ls | grep ape$ | sed 's/.ape//g')
echo "$mp3dir" | while read mp3fl
do
echo -e "$mp3fl"
mkdir "$mp3fl"
done
代码: 全选
#!/bin/bash
# 读取ape文件目录,暂时只能输入绝对路径
read -p "Please enter the directory where APE file is: " apedir
if [ -e "$apedir" ] ; then # 给目录变数appdir
cd $apedir
else
echo -e "The directory does not exists" # 如果目录不存在就退出
exit 0
fi
echo -e "Your are current at $apedir" # 显示出目录名
echo -e "Check if Ape file exists" # 检查ape存见存在与否
if test -e *.[aA][pP][eE] ; then # 用test测试存在与否
echo -e "There is Ape file and the file is"
ls | grep [aA][pP][eE]$
else
echo -e "Not Ape file"
exit 0
fi
apefile=$(ls | grep [aA][Pp][eE]$) # 定义apefile 变数
wavfile=$(echo $apefile | sed 's/[aA][pP][eE]$/wav/g') #定义wav文件变数
cuefile=$(ls | grep [Cc][Uu][Ee]$) # 定义cue变数
mp3file=$(echo $wavfile | sed 's/wav$/wav.mp3/g') # 定义mp3文件变数
#-----------------------------------------------------------------------
#This is testing on the for loop
mac "$(echo $apefile)" "$wavfile" -d # 用mac来转换
lame -h -b 320 "$wavfile" # 用lame 转 mp3
mp3splt -c "$cuefile" -o @n.@t "$mp3file" # 用mp3splt来分割
rm "$mp3file" # 删除前面产生的wav.mp3
cuetag "$cuefile" *.mp3 # 用cuetag写入mp3 tag
read -p "Do you want to del the wav file:[y/n]" wavdel
if [ "$wavdel" == "y" -o "$wavdel" == "Y" ] ; then
echo -e "$wavfile will be removed"
rm "$wavfile"
elif [ "$wavdel" == "n" -o "$wavdel" == "N" ] ; then
echo -e "$wavfile will be kept"
else
echo -e "Your have choosen an invaild option"
fi
read -p "Do you want to del the ape file:[y/n]" apedel
if [ "$apedel" == "y" -o "$apedel" == "Y" ] ; then
echo -e "$apefile will be removed"
rm "$apefile"
elif [ "$apedel" == "n" -o "$apedel" == "N" ] ; then
echo -e "$apefile will be kept"
else
echo - "You have choosen an invaild option"
fi
不过在运行的时候不能用tab只能写绝对路径
第二个就是如果有多个APE和CUE文件会很麻烦 ..
不过我大概想到用for来改了
最后就是有一些gb2312编码的cue文件
不过我用什么指令转换到utf-8都继续呈现乱码
比如
代码: 全选
iconv -f gb2312 -t utf-8 cuefile
代码: 全选
enca -L zh_CN -x utf-8 cuefile
代码: 全选
piconv -f gb2312-raw -t utf-8 cuefile
cue还是问题