I have a folder on my machine with mp3 files in it. however these files are having a leading 3 digit number ; I wanted to rename the files... so I have written the following script but it does not seem to work as expected
#!/bin/sh
cd /home/Ilaya1
files=`ls -rtl | awk '{print $9}'`
for i in $files
do
newname=`echo $i |sed 's/^[0-9]*//'`
mv $i $newname
done
I'm getting the following error:
mv: cannot stat `mila.mp3': No such file or directory
mv: cannot stat `papalu.mp3': No such file or directory
mv: cannot stat `naamugadi11.mp3': No such file or directory
here are the original file names:
107mila mila.mp3
109o papalu.mp3
037chalteka naamugadi11.mp3
note that there are spaces in the file name.
is this the reason why my script is unable to rename them
this is the final output I'm expecting
mila mila.mp3
o papalu.mp3
chalteka naamugadi11.mp3