How to rename multiple folders in Linux using command line

Originally published at:

I am new to Linux programming and bash shell commands. I have a folder structure as dir1, dir2, dir3 and I would like to rename it as dir001, dir002, dir003. How do you rename multiple folders in Linux?

Use a “for loop”.

for i in 1 2 3;do mv dir$i dir00$i;done


for i in $(seq 3);do mv dir$i dir00$i;done
1 Like