How to use mv command to rename multiple files in unix?

Learner picture Learner · Dec 20, 2012 · Viewed 23.8k times · Source

I am trying to rename multiple files with extension xyz[n] to extension xyz

example :

mv *.xyz[1] to *.xyz

but the error is coming as - " *.xyz No such file or directory"

Answer

Anil Tallapragada picture Anil Tallapragada · Dec 20, 2012

Don't know if mv can directly work using * but this would work

find ./ -name "*.xyz\[*\]" | while read line
do 
mv "$line" ${line%.*}.xyz
done