我知道有一些选项,例如“声音转换器”,可以一次对一个音轨或一个目录进行转换,但是是否有任何工具可以递归地遍历目录的子目录并将所有 WMA 转换为 MP3?
我基本上想让它在我的~/Music 上自由运行并让它做它的事情,而不需要我手动一次给它一个子目录。
答案1
安装声音转换器
Soundconverter
并从启动器或终端运行
默认转换是.ogg
将其更改为mp3
结果edit-> preferences
类型下的Format
MP3,如下所示:
点击添加文件夹,然后选择您的音乐文件夹。您可以在上面的首选项配置中选择输出文件夹,然后再点击转换。
希望只需点击两次即可完成:)
答案2
MPlayer 可能已安装。另外请确保您已安装 lame:
sudo apt-get install mplayer lame
然后有两种方法可以做到这一点,一个易于阅读的版本,以及一个简短而肮脏的脚本来做到这一点:
所有 wma 都应位于您的当前目录中。在您的主目录 (~/) 中创建一个名为 wmamp3 的文件,其中包含:
#!/bin/bash
current_directory=$( pwd )
#remove spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done
#remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done
#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader $i && lame -m s audiodump.wav -o $i; done
#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3"; done
#cleanup
rm audiodump.wav
chmod +x ~/wmamp3
使其可执行
sudo cp ~/wmamp3 /usr/bin
将它弹出到路径上有用的地方
输入“wmamp3”来运行转换。
简短而粗糙的版本(与上面的功能完全相同):
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm -ao pcm:waveheader "$i" && lame -m j -h --vbr-new -b 160 audiodump.wav -o "`basename "$i" .wma`.mp3"; done; rm -f audiodump.wav
答案3
必须先安装Mplayer和lame:
sudo apt-get install mplayer lame
然后创建脚本(参考页 )并执行:
#!/bin/bash
# By Marko Haapala
# converts wma to mp3 recursively. does not delete any static files, so
# cleanup and renaming is needed afterwards.
#
# requirements:
# lame - http://lame.sourceforge.net/download.php
# mplayer - apt-get install mplayer or http://www.mplayerhq.hu/design7/dload.html
current_directory=$(pwd)
wma_files=$(find "${current_directory}" -type f -iname "*.wma")
# Need to change IFS or files with filenames containing spaces will not
# be handled correctly by for loop
IFS=$'\n'
for wma_file in ${wma_files}; do
mplayer -vo null -vc dummy -af resample=44100 \
-ao pcm -ao pcm:waveheader "${wma_file}" && lame -m s \
audiodump.wav -o "${wma_file}".mp3
rm audiodump.wav
done
看起来它确实满足了您的要求。请记住,您可能需要摆弄一些蹩脚的标志,以确保获得所需的质量水平。
答案4
我知道这有点旧了,但我修改了 David Futcher 展示的脚本。更改内容如下:
使用
/tmp
它来代替当前文件夹来存放临时的 wav 文件(当我使用它来转换 USB 记忆棒上的文件时,这大大提高了速度)。转换完成后(希望成功),删除 wma 文件。
这里是:
#!/bin/bash
# By Marko Haapala
# converts wma to mp3 recursively. does not delete any static files, so
# cleanup and renaming is needed afterwards.
#
# Modified by V10lator
# to delete the wma files and to use /tmp for temporary files
#
# requirements:
# lame - http://lame.sourceforge.net/download.php
# mplayer - apt-get install mplayer or http://www.mplayerhq.hu/design7/dload.html
current_directory=$(pwd)
tmp_file=$(mktemp -t -u --suffix=.wav)
wma_files=$(find "${current_directory}" -type f -iname "*.wma")
# Need to change IFS or files with filenames containing spaces will not
# be handled correctly by for loop
IFS=$'\n'
for wma_file in ${wma_files}; do
mplayer -vo null -vc dummy -af resample=44100 \
-ao pcm -ao pcm:waveheader -ao pcm:file="${tmp_file}" \
"${wma_file}" && lame -m s "${tmp_file}" \
-o "${wma_file}".mp3 && rm "${wma_file}"
rm "${tmp_file}"
done