This is the part of the script I am using to rename the files returned by ls -A
:
for FILE in `ls -A`
do
ext=${FILE##*.}
NUM=$(($NUM+1))
NEWFILE=`echo $2_$NUM.$ext | sed 's/ /_/g'`
mv "$FILE" "$NEWFILE"
done
But can not find names with space!
The $2 parameter can not be the cause of the error why I ever step a name without a space as a parameter, and this script takes that name and rename all files in the folder so to let them numbered and does not modify the file extension.
Unfortunately it does not rename files with spaces in the name.
Can someone help me?