[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash scripts misrepresenting white space



I'm trying to write a script to create mp3s from flacs, and so far I've
figured out a pretty easy way to do it:
flac -d 01\ Kaneda.flac -c | lame -h -b 192 - 01\ Kaneda.mp3
followed by
id3cp 01\ Kaneda.flac 01\ Kaneda.mp3
(flacs handle id3 tags very nicely)

Of course, I would love to script this. But because all of my flacs
contain whitespace (Files are stored $ARTIST/$ALBUM/$TRACKNUM $TRACKNAME
thereby giving a guaranteed whitespace between num and name). I've had a
problem with scripting and whitespace before, and this is what happens:

I try, for example:
for i in `ls`
do
echo $i
done

and get:
jkoenig@note:~/test.lame$ for i in $( ls ); do echo $i; done
01
Kaneda.flac
01
Kaneda.mp3
02
The
Battle
Against
the
Clowns.flac
... (for the rest of the tracks in this directory)

Anytime I try and use $i, I get only a portion of the filename. Even
using -b and --quoting-style=shell-always with ls to print escape
characters doesn't do anything.

Well, thats my problem. I can't run bash scripts iteratively in
directories where the files contain spaces. Any help would be
appreciated.
-- 
-johann koenig
Now Playing: Social Distortion - Lost Child : Prison Bound
Today is Prickle-Prickle, the 67th day of The Aftermath in the YOLD 3169
My public pgp key: http://mental-graffiti.com/pgp/johannkoenig.pgp

Attachment: pgpkLIBorme8l.pgp
Description: PGP signature


Reply to: