I came up with this:
for i in *;
do input=`echo $i|sed -e 's/[ ]/\\\ /g'`;
output=`echo $input".mp3"`;
mv $input $output; done
Its very close, but it mv complains:
mv: invalid option — ‘\’
I don’t quite get why it won’t work if I try echoing $input or $output they both seem to properly escape all the spaces in the file names and nothing more.
It looks like you are massively over-complicating this with your use of
sed(andecho)…You are trying to escape space characters in file names, but you really just need to enclose the filename in quotation marks. You can simply do…