Click to See Complete Forum and Search --> : Problem with Shell Script and Filenames


gfreehed
05-13-2003, 08:43 PM
I want to do something like this:

for d in `ls *.mp3`; do
mpg123 -w $d.wav $d
done

however, most of my mp3 files have spaces in their names. How do I get this to work without having to rename everything?

rid3r
05-13-2003, 09:54 PM
$ for i in *.mp3 ; do mpg321 -w "$i.wav" "$i"; done
you'll have to learn sed though to rename files correctly. Now they all have *.mp3.wav extension.

gfreehed
05-14-2003, 08:01 AM
Thanks, that worked great.

rid3r
05-15-2003, 12:22 AM
for i in *.mp3 ; do mpg321 -w "`basename \"$i\" .mp3`.wav" "$i" ; done
This one is better.