把当前目录下所有的ogg文件转换为mp3格式

本文介绍如何通过shell命令批量替换文件名中的空格、将OGG格式音频文件转换为MP3格式,并提供了处理MP3到OGG格式转换的方法。针对不同场景,如直接转换失败时提供备用方案,包括先转为WAV再转为MP3的方法。

first replace space with "_"

 

for x in * ; do mv "$x" `echo -n $x | tr " " "_"`; done

 

second: use sox convert ogg to mp3

 

 for x in *.ogg ; do sox $x `echo $x|awk -F . '{print $1 ".mp3"}'`; done




if you occured this error:  sox formats: no handler for file extension `mp3'

you can  convert ogg to wav first, then convert wav to mp3

 

for x in *.ogg ; do sox $x `echo $x|awk -F . '{print $1 ".wav"}'`; done

for x in *.wav ; do lame $x `echo $x|awk -F . '{print $1 ".mp3"}'`; done

 

If you didn't have lame command, you can install use

 

"yum -y install lame"  on fedora

 

 

 

Mp3 to ogg format


mpg321 input.mp3 -w - | oggenc -o output.ogg -



change all mp3 directory to ogg format in current


for x in *mp3; do mpg321 $x -w - | oggenc -o `echo $x |awk -F . '{print $1 ".ogg"}'` -; done


If you didn't have mpg321 command, you can install use

 

"sudo yum install mpg321"  on fedora

 


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值