m4a->mp3 help
Nils Kassube
kassube at gmx.net
Sun Oct 12 11:20:38 UTC 2008
Jonas Norlander wrote:
> 2008/10/12 Nils Kassube <kassube at gmx.net>:
> > You could try this:
> >
> > find ~/Music -iname "*.m4a" | while read fn;do
> > lame -V0 -h -b 160 --vbr-new "$fn" "${fn%[mM]4[aA]}mp3";done
>
> Intresting. Do you mind explain the "${fn%[mM]4[aA]}mp3" part? I
> understand that it will replace m4a with mp3 but i don't understand
> how.
The bash syntax ${fn%m4a} would result in the environment variable $fn
with m4a cut off from the end of the string. However this would only work
if the m4a part is lower case only. However the find option -iname would
also find files with upper case file names. Therefore I used "[mM]"
instead of "m" alone and "[aA]" instead of "a" alone as wildcards because
it will work for both upper and lower case. Finally I want to add "mp3"
to the end of the string which results in "${fn%[mM]4[aA]}mp3" and the
quotes are added just in case there are spaces within the original file
name. If that explanation wasn't good enough, feel free to ask again.
> It should be possible with some sed script to.
Well, if you speak sed that is certainly possible but that would
unnecessarily start sed for every filename :)
Nils
More information about the kubuntu-users
mailing list