[lug] Shell Scripting Help

Dan Ferris dan at usrsbin.com
Tue Feb 14 12:07:10 MST 2006


So, I came into a bunch of MP4 formatted music files from my younger 
brother and naturally, I'd like to convert them to MP3 since dealing 
with MP3s is way easier in the long run at least for me. These aren't 
iTunes encrypted MP4s either, so there is nothing to crack or decrypt, 
just straight conversion.

So being the geek that I am, I had my hopes of making a very simple 
shell script that would go through and convert all the m4a files using 
ffmpeg. Sounds simple right?

So it seems obvious that one could do something like this:

for i in `find . -name "*.m4a"`; do ffmpeg -i "$i" -acodec mp3 -ac 2 -ab 
192 "${i%m4a}mp3"; done && find . -name "*.m4a" -exec rm -f \{\} \;

A one line converter that will run for a few hours and give me the MP3 
files that I so desperately seek and rid my hard disk of the pesky MP4 
files.

However, there is one little caveat and it's driving me INSANE and I'm 
ready to start throwing things.

find will return a file such as this:

./AC_DC/The Razors Edge/01 Thunderstruck.m4a

However, when you try to actually USE this file name in a script it 
shows up like this:

./AC_DC/The
Razors
Edge/01
Thunderstruck.m4a

None of the other commands show strange characters in the file name. 
I've tried to rid the output of funny characters with perl but nothing 
makes it go away.

Thanks!

Dan




More information about the LUG mailing list