[Leaplist] teach me please about this code

tonyb tonyb at abcc.linuxceptional.com
Fri Jan 4 00:51:28 GMT 2008


The easy way to understand it is by using echo to display the
interesting pieces:

I needed to create some m4a files:

touch aa.m4a bb.m4a cc.m4a

Now for the echo statements:

for i in *.m4a
do
  echo "$i"
  echo "${i%m4a}mp3"
done

aa.m4a
aa.mp3
bb.m4a
bb.mp3
cc.m4a
cc.mp3
#

So for each .m4a file in the directory it will run faad and pipe its
output into lame with the new output file name.

Cheers,

Tony
--
May all your bits be in the correct order.


Mr. Brunkow wrote:
> ok today i was in the need of converting m4a to mp3 formats for a video
> editing project.  after a bit of google.com/linux searching i found a
> very easy way to do this with faad and lame.  One of the pages I found
> had a nice little script that would allow me to convert the entire
> directory when 1 command.  I like that.
> 
> Now that I have copied someone else work I want to know what the script
> is telling the computer to do so i understand it a bit better.
> I also found a | line command that does things 1 file at a time and i
> understand that as it is just telling faad to open and lame to convert. 
> simple enough.
> 
> faad -o - inputfile.m4a | lame - outputfile.mp3
> 
> that is easy enough to understand and works great.
> 
> but:
> 
> ------------------------------
> cat convert.sh
> #!/bin/sh
> #
> # m4a to mp3 converting script for a directory
> #
>        for i in *.m4a
>        do
>                faad -o - "$i" | lame -h -b 192 - "${i%m4a}mp3"
>        done
> -------------------------------
> 
> is not so easy to understand.  the #!/bin/sh tells me it is just a bash
> script and i put in the comment about what this script is doing
> 
> but what is the rest?
> 
> thanks for the education.
> 
> 



More information about the Leaplist mailing list