[NTLUG:Discuss] Trivial MP3 conversion script

Daniel Hauck daniel at yacg.com
Sat Jun 7 16:30:23 CDT 2008


Douglas Scott さんは書きました:
> On Saturday 07 June 2008 14:42:13 Russell Lemburg wrote:
>> Logically , I'd set up a parser to find ".wma" and replace it with an empty
>> string.
>>
>> This should work ...
>> rename 's/\.wma.mp3$/\.mp3/' *.wma.mp3
>>
>> On Sat, Jun 7, 2008 at 12:50 PM, Daniel Hauck <daniel at yacg.com> wrote:
>>> I did this:
>>>
>>> for i in *.[Ww][Mm][Aa]; do lame $i ; done
>>>
>>>
>>> The intent and purpose is to convert all WMA files in a folder over to
>>> MP3.  It works, but it leaves "wma" in the resulting filename.
>>>
>>> For example, there is a file called "song.wma" and I run lame against
>>> it, the resulting output file is "song.wma.mp3"
>>>
>>> How can I take the extension off of the file list and then process like
>>> this?
>>>
>>> ... do lame $i.[Ww][Mm][Aa] $i.mp3; done
>>>
>>> What magic code strips off the ".wma"?
>>>
>>>
>>> _______________________________________________
>>> http://www.ntlug.org/mailman/listinfo /discuss
> 
> I did something very similar to convert a batch of wave files to mp3 using 
> lame.  Use basename to get the file name without the extention and then 
> rename the files on the command line.
> 
> ls *.wav |
>    while read file
>    do
>       FILENAME=`basename "$file" .wav`
>       lame -q ${QUALITY} -b ${BITRATE} -s ${SFREQ} \
> 	 --bitwidth ${BITWIDTH} -m ${MODE} \
> 	 "${FILENAME}.wav" "./mp3/${FILENAME}.mp3"
>    done
> 
> Doug

Also very nice code.  I will learn to use that in the stuff I do.  But I
found the ultimate answer... from a command-line perspective anyway:

for i in *.wma ; do audio_conv.py -i "$i" --to-mp3 ; done

You will notice the code being used in the conversion is a python script
that you probably don't already have.  It's here:

http://seismic.ocean.dal.ca/~leblanc/pwp_wiki/static/AudioFormatConversion.html

I have read through the code.  It's pretty slick.  And while there is no
means by which mplayer will simply reveal the WMA tag information, this
script extracts what it does output and puts it to use.  My resulting
MP3s all have ID3Tag information included.



More information about the Discuss mailing list